summaryrefslogtreecommitdiffstats
path: root/src/testdir/test_vim9_class.vim
diff options
context:
space:
mode:
authorYegappan Lakshmanan <yegappan@yahoo.com>2023-10-02 21:43:58 +0200
committerChristian Brabandt <cb@256bit.org>2023-10-02 21:43:58 +0200
commitb32064fedbeb689ecb0481e9473cb7b87d5bb805 (patch)
treeceebd338012f6a58fd4bff67750cfd2938e360e9 /src/testdir/test_vim9_class.vim
parent6d113472601fa6f3a444a95ef7b11d4309215117 (diff)
patch 9.0.1974: vim9: using contra-variant type-checksv9.0.1974
Problem: vim9: using contra-variant type-checks (after v9.0.1959) Solution: Use invariant type checking instead closes: #13248 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/testdir/test_vim9_class.vim')
-rw-r--r--src/testdir/test_vim9_class.vim30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/testdir/test_vim9_class.vim b/src/testdir/test_vim9_class.vim
index 856ee03108..4a92a3d3a2 100644
--- a/src/testdir/test_vim9_class.vim
+++ b/src/testdir/test_vim9_class.vim
@@ -6338,7 +6338,31 @@ def Test_extended_obj_method_type_check()
endclass
class Bar extends Foo
- def Doit(p: A): C
+ def Doit(p: C): B
+ return B.new()
+ enddef
+ endclass
+ END
+ v9.CheckSourceFailure(lines, 'E1383: Method "Doit": type mismatch, expected func(object<B>): object<B> but got func(object<C>): object<B>', 20)
+
+ lines =<< trim END
+ vim9script
+
+ class A
+ endclass
+ class B extends A
+ endclass
+ class C extends B
+ endclass
+
+ class Foo
+ def Doit(p: B): B
+ return B.new()
+ enddef
+ endclass
+
+ class Bar extends Foo
+ def Doit(p: B): C
return C.new()
enddef
endclass
@@ -6362,12 +6386,12 @@ def Test_extended_obj_method_type_check()
endclass
class Bar extends Foo
- def Doit(p: C): B
+ def Doit(p: A): B
return B.new()
enddef
endclass
END
- v9.CheckSourceFailure(lines, 'E1383: Method "Doit": type mismatch, expected func(object<B>): object<B> but got func(object<C>): object<B>', 20)
+ v9.CheckSourceFailure(lines, 'E1383: Method "Doit": type mismatch, expected func(object<B>): object<B> but got func(object<A>): object<B>', 20)
lines =<< trim END
vim9script