src: use MFormalType for type checks when it makes sense
authorJean Privat <jean@pryen.org>
Sat, 4 Apr 2015 09:57:09 +0000 (16:57 +0700)
committerJean Privat <jean@pryen.org>
Sat, 4 Apr 2015 09:57:09 +0000 (16:57 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/highlight.nit
src/metrics/detect_covariance.nit
src/model/model.nit
src/nitni/nitni_callbacks.nit
src/vm/virtual_machine.nit

index ecc4c7d..f4268c0 100644 (file)
@@ -871,7 +871,7 @@ redef class AType
                var mt = mtype
                if mt == null then return null
                mt = mt.as_notnullable
-               if mt isa MVirtualType or mt isa MParameterType then
+               if mt isa MFormalType then
                        res.add_class("nc_vt")
                end
                return mt.infobox(v)
index dd7c36d..5bb2aea 100644 (file)
@@ -445,7 +445,7 @@ redef class MType
                # Now the case of direct null and nullable is over.
 
                # If `sub` is a formal type, then it is accepted if its bound is accepted
-               while sub isa MParameterType or sub isa MVirtualType do
+               while sub isa MFormalType do
                        #print "3.is {sub} a {sup}?"
 
                        # A unfixed formal type can only accept itself
@@ -469,7 +469,7 @@ redef class MType
                assert sub isa MClassType # It is the only remaining type
 
                # A unfixed formal type can only accept itself
-               if sup isa MParameterType or sup isa MVirtualType then
+               if sup isa MFormalType then
                        return false
                end
 
index a5aeb76..bace060 100644 (file)
@@ -713,7 +713,7 @@ abstract class MType
                # Now the case of direct null and nullable is over.
 
                # If `sub` is a formal type, then it is accepted if its bound is accepted
-               while sub isa MParameterType or sub isa MVirtualType do
+               while sub isa MFormalType do
                        #print "3.is {sub} a {sup}?"
 
                        # A unfixed formal type can only accept itself
@@ -737,7 +737,7 @@ abstract class MType
                assert sub isa MClassType # It is the only remaining type
 
                # A unfixed formal type can only accept itself
-               if sup isa MParameterType or sup isa MVirtualType then
+               if sup isa MFormalType then
                        return false
                end
 
index f53466c..8542a95 100644 (file)
@@ -111,7 +111,7 @@ redef class AMethPropdef
                # return type
                var rmt = mpropdef.msignature.return_mtype
                if rmt != null then
-                       if rmt isa MParameterType or rmt isa MVirtualType then
+                       if rmt isa MFormalType then
                                var mclass_type = mpropdef.mclassdef.bound_mtype
                                rmt = rmt.anchor_to(mmodule, mclass_type)
                        end
@@ -122,7 +122,7 @@ redef class AMethPropdef
                # params
                for p in mpropdef.msignature.mparameters do
                        var mtype = p.mtype.resolve_for(recv_type, recv_type, mmodule, true)
-                       if mtype isa MParameterType or mtype isa MVirtualType then
+                       if mtype isa MFormalType then
                                var mclass_type = mpropdef.mclassdef.bound_mtype
                                mtype = mtype.anchor_to(mmodule, mclass_type)
                        end
@@ -308,7 +308,7 @@ redef class AFullPropExternCall
 
                if mtype == null then return
 
-               if mtype isa MParameterType or mtype isa MVirtualType then
+               if mtype isa MFormalType then
                        mtype = mtype.anchor_to(mmodule, mclass_type)
                end
 
index b33e7f8..9c3d516 100644 (file)
@@ -61,10 +61,10 @@ class VirtualMachine super NaiveInterpreter
                var anchor = self.frame.arguments.first.mtype.as(MClassType)
 
                # `sub` or `sup` are formal or virtual types, resolve them to concrete types
-               if sub isa MParameterType or sub isa MVirtualType then
+               if sub isa MFormalType then
                        sub = sub.resolve_for(anchor.mclass.mclass_type, anchor, mainmodule, false)
                end
-               if sup isa MParameterType or sup isa MVirtualType then
+               if sup isa MFormalType then
                        sup = sup.resolve_for(anchor.mclass.mclass_type, anchor, mainmodule, false)
                end
 
@@ -87,7 +87,7 @@ class VirtualMachine super NaiveInterpreter
                end
                # Now the case of direct null and nullable is over
 
-               if sub isa MParameterType or sub isa MVirtualType then
+               if sub isa MFormalType then
                        sub = sub.anchor_to(mainmodule, anchor)
                        # Manage the second layer of null/nullable
                        if sub isa MNullableType then