From b6eaab43fef727df286e7d654c5a89eae41e3684 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Sat, 4 Apr 2015 16:57:09 +0700 Subject: [PATCH] src: use MFormalType for type checks when it makes sense Signed-off-by: Jean Privat --- src/highlight.nit | 2 +- src/metrics/detect_covariance.nit | 4 ++-- src/model/model.nit | 4 ++-- src/nitni/nitni_callbacks.nit | 6 +++--- src/vm/virtual_machine.nit | 6 +++--- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/highlight.nit b/src/highlight.nit index ecc4c7d..f4268c0 100644 --- a/src/highlight.nit +++ b/src/highlight.nit @@ -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) diff --git a/src/metrics/detect_covariance.nit b/src/metrics/detect_covariance.nit index dd7c36d..5bb2aea 100644 --- a/src/metrics/detect_covariance.nit +++ b/src/metrics/detect_covariance.nit @@ -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 diff --git a/src/model/model.nit b/src/model/model.nit index a5aeb76..bace060 100644 --- a/src/model/model.nit +++ b/src/model/model.nit @@ -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 diff --git a/src/nitni/nitni_callbacks.nit b/src/nitni/nitni_callbacks.nit index f53466c..8542a95 100644 --- a/src/nitni/nitni_callbacks.nit +++ b/src/nitni/nitni_callbacks.nit @@ -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 diff --git a/src/vm/virtual_machine.nit b/src/vm/virtual_machine.nit index b33e7f8..9c3d516 100644 --- a/src/vm/virtual_machine.nit +++ b/src/vm/virtual_machine.nit @@ -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 -- 1.7.9.5