forked from aniani/vim
patch 9.0.1974: vim9: using contra-variant type-checks
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>
This commit is contained in:
committed by
Christian Brabandt
parent
6d11347260
commit
b32064fedb
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user