Resolve the formal type to its simplest equivalent form.

Formal types are either free or fixed. When it is fixed, it means that it is equivalent with a simpler type. When a formal type is free, it means that it is only equivalent with itself. This method return the most simple equivalent type of self.

This method is mainly used for subtype test in order to sanely compare fixed.

By default, return self. See the redefinitions for specific behavior in each kind of type.

In case of conflicts or inconsistencies in the model, the method returns a MErrorType.

Property definitions

nitc $ MType :: lookup_fixed
	# Resolve the formal type to its simplest equivalent form.
	#
	# Formal types are either free or fixed.
	# When it is fixed, it means that it is equivalent with a simpler type.
	# When a formal type is free, it means that it is only equivalent with itself.
	# This method return the most simple equivalent type of `self`.
	#
	# This method is mainly used for subtype test in order to sanely compare fixed.
	#
	# By default, return self.
	# See the redefinitions for specific behavior in each kind of type.
	#
	# In case of conflicts or inconsistencies in the model, the method returns a `MErrorType`.
	fun lookup_fixed(mmodule: MModule, resolved_receiver: MType): MType do return self
src/model/model.nit:1135,2--1148,83

nitc $ MProxyType :: lookup_fixed
	redef fun lookup_fixed(mmodule, resolved_receiver)
	do
		var t = mtype.lookup_fixed(mmodule, resolved_receiver)
		return t
	end
src/model/model.nit:1801,2--1805,4

nitc $ MVirtualType :: lookup_fixed
	# A VT is fixed when:
	# * the VT is (re-)defined with the annotation `is fixed`
	# * the receiver is an enum class since there is no subtype that can
	#   redefine this virtual type
	redef fun lookup_fixed(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 prop = lookup_single_definition(mmodule, resolved_receiver)
		var res = prop.bound
		if res == null then return new MErrorType(model)

		# Recursively lookup the fixed result
		res = res.lookup_fixed(mmodule, resolved_receiver)

		# For a fixed VT, return the resolved bound
		if prop.is_fixed then return res

		# For a enum receiver return the bound
		if resolved_receiver.mclass.kind == enum_kind then return res

		return self
	end
src/model/model.nit:1555,2--1579,4

nitc $ MParameterType :: lookup_fixed
	# A PT is fixed when:
	# * The `resolved_receiver` is a subclass of `self.mclass`,
	#   so it is necessarily fixed in a `super` clause, either with a normal type
	#   or with another PT.
	#   See `resolve_for` for examples about related issues.
	redef fun lookup_fixed(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 res = self.resolve_for(resolved_receiver.mclass.mclass_type, resolved_receiver, mmodule, false)
		return res
	end
src/model/model.nit:1695,2--1707,4

nitc $ MNullableType :: lookup_fixed
	# Efficiently returns `mtype.lookup_fixed(mmodule, resolved_receiver).as_nullable`
	redef fun lookup_fixed(mmodule, resolved_receiver)
	do
		var t = super
		if t == mtype then return self
		return t.as_nullable
	end
src/model/model.nit:1852,2--1858,4

nitc $ MNotNullType :: lookup_fixed
	# Efficiently returns `mtype.lookup_fixed(mmodule, resolved_receiver).as_notnull`
	redef fun lookup_fixed(mmodule, resolved_receiver)
	do
		var t = super
		if t == mtype then return self
		return t.as_notnull
	end
src/model/model.nit:1881,2--1887,4