From 8c287fe37bbadc092de31c36173b1f8601bff65d Mon Sep 17 00:00:00 2001 From: Jean Privat Date: Tue, 22 Jul 2014 22:20:08 -0400 Subject: [PATCH] tests: add base_virtual_type_fixed.nit Signed-off-by: Jean Privat --- tests/base_virtual_type_fixed.nit | 38 ++++++++++++++++++++++++++++ tests/sav/base_virtual_type_fixed.res | 2 ++ tests/sav/base_virtual_type_fixed_alt1.res | 2 ++ 3 files changed, 42 insertions(+) create mode 100644 tests/base_virtual_type_fixed.nit create mode 100644 tests/sav/base_virtual_type_fixed.res create mode 100644 tests/sav/base_virtual_type_fixed_alt1.res diff --git a/tests/base_virtual_type_fixed.nit b/tests/base_virtual_type_fixed.nit new file mode 100644 index 0000000..cc0248b --- /dev/null +++ b/tests/base_virtual_type_fixed.nit @@ -0,0 +1,38 @@ +# 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 A + type V1: Object + fun v1(v: V1): V1 do return v + type V2: Object + fun v2(v: V2): V2 do return v +end +interface B + super A + redef type V1: Discrete + redef type V2: Discrete is fixed +end +class C + super B + + # Because of the workaround, there is no simple way to see the subtype relation + #alt1#redef fun v1(v: Discrete): Discrete do return v + redef fun v2(v: Discrete): Discrete do return v +end + +var c: A = new C +c.v1(1).output +c.v1(2).output diff --git a/tests/sav/base_virtual_type_fixed.res b/tests/sav/base_virtual_type_fixed.res new file mode 100644 index 0000000..1191247 --- /dev/null +++ b/tests/sav/base_virtual_type_fixed.res @@ -0,0 +1,2 @@ +1 +2 diff --git a/tests/sav/base_virtual_type_fixed_alt1.res b/tests/sav/base_virtual_type_fixed_alt1.res new file mode 100644 index 0000000..e1f51ca --- /dev/null +++ b/tests/sav/base_virtual_type_fixed_alt1.res @@ -0,0 +1,2 @@ +alt/base_virtual_type_fixed_alt1.nit:32,15--25: Redef Error: Wrong type for parameter `v'. found Discrete, expected V1 as in base_virtual_type_fixed_alt1#A#v1. +alt/base_virtual_type_fixed_alt1.nit:32,29--36: Redef Error: Wrong return type. found Discrete, expected V1 as in base_virtual_type_fixed_alt1#A#v1. -- 1.7.9.5