Skip to content

Commit

Permalink
checker: fix interface param resolution (#18780)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jul 5, 2023
1 parent 4a19698 commit 072364f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion vlib/v/checker/fn.v
Expand Up @@ -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
}
Expand Down
12 changes: 10 additions & 2 deletions vlib/v/tests/iface_arg_test.v
Expand Up @@ -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() {
Expand All @@ -26,3 +26,11 @@ fn test_main() {

assert true
}

fn test_ptr() {
mut a := Cmdable{}
a.call = test
a.call(get())

assert true
}

0 comments on commit 072364f

Please sign in to comment.