modelize_mproperty: fix virtual type redef on already defined type
authorAlexandre Terrasa <alexandre@moz-code.org>
Thu, 27 Feb 2014 18:19:28 +0000 (13:19 -0500)
committerAlexandre Terrasa <alexandre@moz-code.org>
Thu, 27 Feb 2014 18:19:28 +0000 (13:19 -0500)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/modelize_property.nit
tests/base_virtual_type_redef.nit [new file with mode: 0644]
tests/sav/base_virtual_type_redef.res [new file with mode: 0644]

index d946c12..89eb0f3 100644 (file)
@@ -882,6 +882,9 @@ redef class ATypePropdef
 
        redef fun check_signature(modelbuilder, nclassdef)
        do
+               var mpropdef = self.mpropdef
+               if mpropdef == null then return # Error thus skiped
+
                var bound = self.mpropdef.bound
 
                # Fast case: the bound is not a formal type
diff --git a/tests/base_virtual_type_redef.nit b/tests/base_virtual_type_redef.nit
new file mode 100644 (file)
index 0000000..837bd46
--- /dev/null
@@ -0,0 +1,26 @@
+# This file is part of NIT ( http://www.nitlanguage.org ).
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+import kernel
+
+interface Number
+       type OTHER: Number
+end
+
+redef class Int
+       super Number
+
+       redef type OTHER: Int
+end
+
diff --git a/tests/sav/base_virtual_type_redef.res b/tests/sav/base_virtual_type_redef.res
new file mode 100644 (file)
index 0000000..0a956f4
--- /dev/null
@@ -0,0 +1,2 @@
+base_virtual_type_redef.nit:24,13--17: Ambigous property name 'OTHER' for Int; conflict between base_virtual_type_redef::Number::OTHER and standard::kernel::Comparable::OTHER
+base_virtual_type_redef.nit:24,2--22: Error: No property Int::OTHER is inherited. Remove the redef keyword to define a new property.