From 3dda171d276683458c45e435a51bc68774c00a33 Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Fri, 25 Mar 2011 17:01:35 -0400 Subject: [PATCH] typing: do not crash on inherited invalid signature Signed-off-by: Jean Privat --- src/syntax/mmbuilder.nit | 4 +++- tests/error_signature.nit | 29 +++++++++++++++++++++++++++++ tests/sav/error_signature.sav | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 tests/error_signature.nit create mode 100644 tests/sav/error_signature.sav diff --git a/src/syntax/mmbuilder.nit b/src/syntax/mmbuilder.nit index 3534938..ce875a8 100644 --- a/src/syntax/mmbuilder.nit +++ b/src/syntax/mmbuilder.nit @@ -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 index 0000000..7da246a --- /dev/null +++ b/tests/error_signature.nit @@ -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 index 0000000..6df6145 --- /dev/null +++ b/tests/sav/error_signature.sav @@ -0,0 +1 @@ +./error_signature.nit:18,11--14: Type error: class Fail not found in module error_signature. -- 1.7.9.5