The selection knows that refinement is stronger than specialization; however, in case of conflict more than one property are returned. If mtype does not know mproperty then an empty array is returned.
If you want the really most specific property, then look at lookup_next_definition
REQUIRE: not mtype.need_anchor
to simplify the API (no anchor
parameter)
ENSURE: not mtype.has_mproperty(mmodule, self) implies result.is_empty
# Return the most specific property definitions inherited by a type.
# The selection knows that refinement is stronger than specialization;
# however, in case of conflict more than one property are returned.
# If mtype does not know mproperty then an empty array is returned.
#
# If you want the really most specific property, then look at `lookup_next_definition`
#
# REQUIRE: `not mtype.need_anchor` to simplify the API (no `anchor` parameter)
# ENSURE: `not mtype.has_mproperty(mmodule, self) implies result.is_empty`
fun lookup_super_definitions(mmodule: MModule, mtype: MType): Array[MPROPDEF]
do
assert not mtype.need_anchor
mtype = mtype.undecorate
# First, select all candidates
var candidates = new Array[MPROPDEF]
for mpropdef in self.mpropdefs do
# If the definition is not imported by the module, then skip
if not mmodule.in_importation <= mpropdef.mclassdef.mmodule then continue
# If the definition is not inherited by the type, then skip
if not mtype.is_subtype(mmodule, null, mpropdef.mclassdef.bound_mtype) then continue
# If the definition is defined by the type, then skip (we want the super, so e skip the current)
if mtype == mpropdef.mclassdef.bound_mtype and mmodule == mpropdef.mclassdef.mmodule then continue
# Else, we keep it
candidates.add(mpropdef)
end
# Fast track for only one candidate
if candidates.length <= 1 then return candidates
# Second, filter the most specific ones
return select_most_specific(mmodule, candidates)
end
src/model/model.nit:2273,2--2304,4