src: improve messages (and sometime location) of errors and warnings
[nit.git] / src / ffi / extern_classes.nit
index bc4f0c4..6b53008 100644 (file)
@@ -38,8 +38,8 @@ private class ExternClassesTypingPhaseAst
                if code_block == null then return
 
                if nclassdef.n_kwredef != null then
-                       # A redef cannot specifiy a different extern type
-                       toolcontext.error(nclassdef.location, "Only the introduction of a class can specify an extern type.")
+                       # A redef cannot specify a different extern type
+                       toolcontext.error(nclassdef.location, "FFI Error: only the introduction of a class can declare an extern type.")
                        return
                end
 
@@ -68,10 +68,11 @@ private class ExternClassesTypingPhaseModel
                if not nclassdef isa AStdClassdef then return
 
                var mclassdef = nclassdef.mclassdef
-               var mclass = nclassdef.mclass
+               if mclassdef == null then return
+               var mclass = mclassdef.mclass
 
                # We only need to do this once per class
-               if mclass.intro != mclassdef then return
+               if not mclassdef.is_intro then return
 
                if mclass.kind != extern_kind then return
 
@@ -117,7 +118,7 @@ redef class MClass
                                        else
                                                # detect conflict
                                                if super_ftype != ftype_b then
-                                                       v.toolcontext.error(null, "Extern type conflict in {self}")
+                                                       v.toolcontext.error(null, "FFI Error: extern type conflict in `{self}`.")
                                                        return null
                                                end
                                        end