modelize_class: Force `Object` to be an interface
authorJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Thu, 4 Aug 2016 16:38:53 +0000 (12:38 -0400)
committerJean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>
Thu, 4 Aug 2016 16:38:53 +0000 (12:38 -0400)
Signed-off-by: Jean-Christophe Beaupré <jcbrinfo@users.noreply.github.com>

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

index 045e829..50a350c 100644 (file)
@@ -280,9 +280,14 @@ redef class ModelBuilder
                        if mclass.kind == extern_kind and mclass.name != "Pointer" then
                                # it is an extern class, but not a Pointer
                                if specpointer then supertypes.add pointerclass.mclass_type
-                       else if specobject and mclass.name != "Object" then
-                               # it is a standard class without super class (but is not Object)
-                               supertypes.add objectclass.mclass_type
+                       else if specobject then
+                               if mclass.name != "Object" then
+                                       # it is a standard class without super class (but is not Object)
+                                       supertypes.add objectclass.mclass_type
+                               else if mclass.kind != interface_kind then
+                                       error(nclassdef, "Error: `Object` must be an {interface_kind}.")
+                                       return
+                               end
                        end
                end
 
diff --git a/tests/sav/test_object_class_kind_alt1.res b/tests/sav/test_object_class_kind_alt1.res
new file mode 100644 (file)
index 0000000..3afdf0e
--- /dev/null
@@ -0,0 +1 @@
+alt/test_object_class_kind_alt1.nit:18,16--21: Error: `Object` must be an interface.
diff --git a/tests/sav/test_object_class_kind_alt2.res b/tests/sav/test_object_class_kind_alt2.res
new file mode 100644 (file)
index 0000000..9756e60
--- /dev/null
@@ -0,0 +1 @@
+alt/test_object_class_kind_alt2.nit:19,7--12: Error: `Object` must be an interface.
diff --git a/tests/sav/test_object_class_kind_alt3.res b/tests/sav/test_object_class_kind_alt3.res
new file mode 100644 (file)
index 0000000..2641394
--- /dev/null
@@ -0,0 +1 @@
+alt/test_object_class_kind_alt3.nit:20,6--11: Error: `Object` must be an interface.