typing: do not crash on inherited invalid signature
authorJean Privat <jean@pryen.org>
Fri, 25 Mar 2011 21:01:35 +0000 (17:01 -0400)
committerJean Privat <jean@pryen.org>
Thu, 31 Mar 2011 14:53:27 +0000 (10:53 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/syntax/mmbuilder.nit
tests/error_signature.nit [new file with mode: 0644]
tests/sav/error_signature.sav [new file with mode: 0644]

index 3534938..ce875a8 100644 (file)
@@ -845,7 +845,9 @@ redef class APropdef
                #print "process {prop.local_class.mmmodule}::{prop.local_class}::{prop} from global {prop.global.local_property.local_class.mmmodule}::{prop.global.local_property.local_class}::{prop.global.local_property}"
                for i in prop.prhe.direct_greaters do
                        var ip = i.local_class[prop.global]
-                       var isig = i.signature.adaptation_to(v.local_class.get_type)
+                       var isig = i.signature
+                       if isig == null then break # previous signature is invalid
+                       isig = isig.adaptation_to(v.local_class.get_type)
 
                        if s == null then
                                #print "{prop.full_name} inherits signature from {ip.full_name}"
diff --git a/tests/error_signature.nit b/tests/error_signature.nit
new file mode 100644 (file)
index 0000000..7da246a
--- /dev/null
@@ -0,0 +1,29 @@
+# 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
+
+class A
+       fun foo: Fail do return 1
+end
+
+class B
+       super A
+       redef fun foo do return 2
+end
+
+class C
+       super A
+       redef fun foo: Int do return 3
+end
diff --git a/tests/sav/error_signature.sav b/tests/sav/error_signature.sav
new file mode 100644 (file)
index 0000000..6df6145
--- /dev/null
@@ -0,0 +1 @@
+./error_signature.nit:18,11--14: Type error: class Fail not found in module error_signature.