1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: fix interface param resolution (#18780)

This commit is contained in:
Felipe Pena 2023-07-05 17:26:44 -03:00 committed by GitHub
parent 4a196989a9
commit 072364fc59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -1723,7 +1723,7 @@ fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
}
if c.table.sym(param.typ).kind == .interface_ {
// cannot hide interface expected type to make possible to pass its interface type automatically
earg_types << param.typ.set_nr_muls(targ.nr_muls())
earg_types << if targ.idx() != param.typ.idx() { param.typ } else { targ }
} else {
earg_types << targ
}

View File

@ -13,8 +13,8 @@ fn (t Test) test(a ITest) {}
fn test(a ITest) {}
fn get() Test {
return Test{}
fn get() &Test {
return &Test{}
}
fn test_main() {
@ -26,3 +26,11 @@ fn test_main() {
assert true
}
fn test_ptr() {
mut a := Cmdable{}
a.call = test
a.call(get())
assert true
}