src: use `as_notnullable` in code
[nit.git] / src / nitni / nitni_callbacks.nit
index 6f85029..cb75bc8 100644 (file)
@@ -298,9 +298,8 @@ redef class AFullPropExternCall
        do
                var mmodule = npropdef.mpropdef.mclassdef.mmodule
                var mclassdef = npropdef.mpropdef.mclassdef
-               var nclassdef = toolcontext.modelbuilder.mclassdef2nclassdef[mclassdef]
                var mclass_type = mclassdef.bound_mtype
-               var mtype = toolcontext.modelbuilder.resolve_mtype(nclassdef, n_type)
+               var mtype = toolcontext.modelbuilder.resolve_mtype(mmodule, mclassdef, n_type)
 
                if mtype == null then return
 
@@ -333,8 +332,7 @@ redef class AInitPropExternCall
        do
                var mmodule = npropdef.mpropdef.mclassdef.mmodule
                var mclassdef = npropdef.mpropdef.mclassdef
-               var nclassdef = toolcontext.modelbuilder.mclassdef2nclassdef[mclassdef]
-               var mtype = toolcontext.modelbuilder.resolve_mtype(nclassdef, n_type)
+               var mtype = toolcontext.modelbuilder.resolve_mtype(mmodule, mclassdef, n_type)
                if mtype == null then return
 
                if not mtype isa MClassType then
@@ -388,9 +386,10 @@ redef class ACastAsExternCall
 
        redef fun verify_and_collect(npropdef, callback_set, toolcontext)
        do
-               var parent_aclassdef = npropdef.parent.as(AClassdef)
-               toolcontext.modelbuilder.resolve_mtype_unchecked(parent_aclassdef, n_from_type, true)
-               toolcontext.modelbuilder.resolve_mtype_unchecked(parent_aclassdef, n_to_type, true)
+               var mclassdef = npropdef.mpropdef.mclassdef
+               var mmodule = mclassdef.mmodule
+               toolcontext.modelbuilder.resolve_mtype_unchecked(mmodule, mclassdef, n_from_type, true)
+               toolcontext.modelbuilder.resolve_mtype_unchecked(mmodule, mclassdef, n_to_type, true)
                super
        end
 end
@@ -401,8 +400,9 @@ redef class AAsNullableExternCall
 
        redef fun verify_and_collect(npropdef, callback_set, toolcontext)
        do
-               var parent_aclassdef = npropdef.parent.as(AClassdef)
-               toolcontext.modelbuilder.resolve_mtype_unchecked(parent_aclassdef, n_type, true)
+               var mclassdef = npropdef.mpropdef.mclassdef
+               var mmodule = mclassdef.mmodule
+               toolcontext.modelbuilder.resolve_mtype_unchecked(mmodule, mclassdef, n_type, true)
                super
        end
 end
@@ -411,14 +411,15 @@ redef class AAsNotNullableExternCall
        redef fun from_mtype do return n_type.mtype.as_nullable
        redef fun to_mtype do
                var mtype = n_type.mtype.as(not null)
-               if mtype isa MNullableType then return mtype.mtype
+               mtype = mtype.as_notnullable
                return mtype
        end
 
        redef fun verify_and_collect(npropdef, callback_set, toolcontext)
        do
-               var parent_aclassdef = npropdef.parent.as(AClassdef)
-               toolcontext.modelbuilder.resolve_mtype_unchecked(parent_aclassdef, n_type, true)
+               var mclassdef = npropdef.mpropdef.mclassdef
+               var mmodule = mclassdef.mmodule
+               toolcontext.modelbuilder.resolve_mtype_unchecked(mmodule, mclassdef, n_type, true)
                super
        end
 end