model: handle BottomType in `is_subtype`
authorJean Privat <jean@pryen.org>
Wed, 28 Oct 2015 15:50:45 +0000 (11:50 -0400)
committerJean Privat <jean@pryen.org>
Thu, 29 Oct 2015 12:36:27 +0000 (08:36 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/model/model.nit

index 3841daf..851efda 100644 (file)
@@ -809,19 +809,19 @@ abstract class MType
                end
                #print "4.is {sub} a {sup}? <- no more resolution"
 
-               assert sub isa MClassType else print "{sub} <? {sub}" # It is the only remaining type
-
-               # A unfixed formal type can only accept itself
-               if sup isa MFormalType then
-                       return false
+               if sub isa MBottomType then
+                       return true
                end
 
-               if sup isa MNullType then
-                       # `sup` accepts only null
+               assert sub isa MClassType else print "{sub} <? {sub}" # It is the only remaining type
+
+               # Handle sup-type when the sub-type is class-based (other cases must have be identified before).
+               if sup isa MFormalType or sup isa MNullType or sup isa MBottomType then
+                       # These types are not super-types of Class-based types.
                        return false
                end
 
-               assert sup isa MClassType # It is the only remaining type
+               assert sup isa MClassType else print "got {sup} {sub.inspect}" # It is the only remaining type
 
                # Now both are MClassType, we need to dig