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
@@ -925,10 +925,14 @@ check_type_maybe(
|
||||
if (actual->tt_class == NULL)
|
||||
return OK; // A null object matches
|
||||
|
||||
// For object method arguments, do a contra-variance type check in
|
||||
// an extended class. For all others, do a co-variance type check.
|
||||
if (class_instance_of(actual->tt_class, expected->tt_class,
|
||||
where.wt_kind != WT_METHOD_ARG) == FALSE)
|
||||
// For object method arguments, do a invariant type check in
|
||||
// an extended class. For all others, do a covariance type check.
|
||||
if (where.wt_kind == WT_METHOD_ARG)
|
||||
{
|
||||
if (actual->tt_class != expected->tt_class)
|
||||
ret = FAIL;
|
||||
}
|
||||
else if (!class_instance_of(actual->tt_class, expected->tt_class))
|
||||
ret = FAIL;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user