modelize_class: Do not crash if `Pointer` is not defined
authorJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Thu, 4 Aug 2016 16:39:53 +0000 (12:39 -0400)
committerJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Thu, 4 Aug 2016 16:39:53 +0000 (12:39 -0400)
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

src/modelize/modelize_class.nit
tests/sav/test_object_class_kind_alt4.res [new file with mode: 0644]

index 50a350c..2dfac9c 100644 (file)
@@ -279,6 +279,10 @@ redef class ModelBuilder
                if mclassdef.is_intro and objectclass != null then
                        if mclass.kind == extern_kind and mclass.name != "Pointer" then
                                # it is an extern class, but not a Pointer
+                               if pointerclass == null then
+                                       error(nclassdef, "Error: `Pointer` must be defined first.")
+                                       return
+                               end
                                if specpointer then supertypes.add pointerclass.mclass_type
                        else if specobject then
                                if mclass.name != "Object" then
diff --git a/tests/sav/test_object_class_kind_alt4.res b/tests/sav/test_object_class_kind_alt4.res
new file mode 100644 (file)
index 0000000..19f4896
--- /dev/null
@@ -0,0 +1 @@
+alt/test_object_class_kind_alt4.nit:21,14--19: Error: `Pointer` must be defined first.