class MMTypeProperty
special MMLocalProperty
# The virtual static type associated
- meth stype_for(recv: MMType): MMVirtualType
+ meth stype_for(recv: MMType): nullable MMVirtualType
do
- var prop = recv.select_property(global)
+ var prop = recv.local_class[global]
assert prop isa MMTypeProperty
return prop.real_stype_for(recv)
end
# Cached results of stype
attr _stypes_cache: HashMap[MMType, MMVirtualType] = new HashMap[MMType, MMVirtualType]
- private meth real_stype_for(recv: MMType): MMVirtualType
+ private meth real_stype_for(recv: MMType): nullable MMVirtualType
do
# If the signature is not build: Circular definition
if signature == null then return null
end
end
-redef class MMType
- # Select a virtual type property by its name
- meth select_virtual_type(name: Symbol): MMTypeProperty
- do
- assert local_class != null
- assert name != null
- var res = select_property(local_class.virtual_type(name))
- assert res isa MMTypeProperty
- return res
- end
-end
-
class MMVirtualType
special MMTypeFormal
# The property associed
redef meth adapt_to(recv)
do
- return property.stype_for(recv)
+ return property.stype_for(recv).as(not null)
end
end
if prop.is_virtual_type then
return prop
end
- return null
+ abort
+ end
+
+ # Select a virtual type property by its name
+ meth select_virtual_type(name: Symbol): MMTypeProperty
+ do
+ var gp = virtual_type(name)
+ var res = self[gp]
+ assert res isa MMTypeProperty
+ return res
end
end