modelize_property: do not crash if mtype is null in check_visibility
[nit.git] / src / modelize_property.nit
index eed8e9d..159523b 100644 (file)
@@ -96,9 +96,13 @@ redef class ModelBuilder
                        if not c.kind.need_init then continue
                        st = st.anchor_to(mmodule, mclassdef.bound_mtype)
                        var candidate = self.try_get_mproperty_by_name2(nclassdef, mmodule, st, "init").as(nullable MMethod)
-                       if candidate != null and candidate.intro.msignature.arity == 0 then
-                               combine.add(candidate)
-                               continue
+                       if candidate != null then
+                               if candidate.intro.msignature != null then
+                                       if candidate.intro.msignature.arity == 0 then
+                                               combine.add(candidate)
+                                               continue
+                                       end
+                               end
                        end
                        var inhc2 = c.inherit_init_from
                        if inhc2 == null then inhc2 = c
@@ -201,7 +205,11 @@ redef class ModelBuilder
 
                # No error, try to go deeper in generic types
                if node isa AType then
-                       for a in node.n_types do check_visibility(a, a.mtype.as(not null), mpropdef)
+                       for a in node.n_types do
+                               var t = a.mtype
+                               if t == null then continue # Error, thus skipped
+                               check_visibility(a, t, mpropdef)
+                       end
                else if mtype isa MGenericType then
                        for t in mtype.arguments do check_visibility(node, t, mpropdef)
                end
@@ -712,7 +720,7 @@ redef class AAttrPropdef
                                mwriteprop = new MMethod(mclassdef, writename, mvisibility)
                                if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef, false, mwriteprop) then return
                        else
-                               if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef, true, mwriteprop) then return
+                               if not self.check_redef_keyword(modelbuilder, mclassdef, nwkwredef or else n_kwredef, true, mwriteprop) then return
                                if nwritable != null then
                                        check_redef_property_visibility(modelbuilder, nwritable.n_visibility, mwriteprop)
                                end
@@ -877,7 +885,7 @@ redef class AAttrPropdef
                                for i in [0..mysignature.arity[ do
                                        var myt = mysignature.mparameters[i].mtype
                                        var prt = msignature.mparameters[i].mtype
-                                       if not myt.is_subtype(mmodule, mclassdef.bound_mtype, prt) and
+                                       if not myt.is_subtype(mmodule, mclassdef.bound_mtype, prt) or
                                                        not prt.is_subtype(mmodule, mclassdef.bound_mtype, myt) then
                                                var node: ANode
                                                if nsig != null then node = nsig else node = self