nitc :: MType :: lookup_bound
If the type is not formal, just return self
The result is returned exactly as declared in the "type" property (verbatim). So it could be another formal type.
In case of conflicts or inconsistencies in the model, the method returns a MErrorType
.
# Resolve formal type to its verbatim bound.
# If the type is not formal, just return self
#
# The result is returned exactly as declared in the "type" property (verbatim).
# So it could be another formal type.
#
# In case of conflicts or inconsistencies in the model, the method returns a `MErrorType`.
fun lookup_bound(mmodule: MModule, resolved_receiver: MType): MType do return self
src/model/model.nit:1126,2--1133,83
redef fun lookup_bound(mmodule, resolved_receiver)
do
# There is two possible invalid cases: the vt does not exists in resolved_receiver or the bound is broken
if not resolved_receiver.has_mproperty(mmodule, mproperty) then return new MErrorType(model)
return lookup_single_definition(mmodule, resolved_receiver).bound or else new MErrorType(model)
end
src/model/model.nit:1527,2--1532,4
redef fun lookup_bound(mmodule: MModule, resolved_receiver: MType): MType
do
assert not resolved_receiver.need_anchor
resolved_receiver = resolved_receiver.undecorate
assert resolved_receiver isa MClassType # It is the only remaining type
var goalclass = self.mclass
if resolved_receiver.mclass == goalclass then
return resolved_receiver.arguments[self.rank]
end
var supertypes = resolved_receiver.collect_mtypes(mmodule)
for t in supertypes do
if t.mclass == goalclass then
# Yeah! c specialize goalclass with a "super `t'". So the question is what is the argument of f
# FIXME: Here, we stop on the first goal. Should we check others and detect inconsistencies?
var res = t.arguments[self.rank]
return res
end
end
# Cannot found `self` in `resolved_receiver`
return new MErrorType(model)
end
src/model/model.nit:1673,2--1693,4