Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Jun 30, 2023
1 parent 015ccc2 commit d8e1e9d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vlib/v/checker/fn.v
Original file line number Diff line number Diff line change
Expand Up @@ -1712,13 +1712,17 @@ fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type {
for i, mut arg in node.args {
targ := c.check_expr_opt_call(arg.expr, c.expr(arg.expr))
arg.typ = targ
earg_types << targ

param := if info.func.is_variadic && i >= info.func.params.len - 1 {
info.func.params.last()
} else {
info.func.params[i]
}
if c.table.sym(param.typ).kind == .interface_ {
earg_types << param.typ
} else {
earg_types << targ
}
param_share := param.typ.share()
if param_share == .shared_t
&& (c.locked_names.len > 0 || c.rlocked_names.len > 0) {
Expand Down
28 changes: 28 additions & 0 deletions vlib/v/tests/iface_arg_test.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
interface ITest {
}

struct Test {
}

struct Cmdable {
mut:
call fn (cmd ITest)
}

fn (t Test) test(a ITest) {}

fn test(a ITest) {}

fn get() Test {
return Test{}
}

fn test_main() {
mut a := Cmdable{}
a.call = test
a.call(Test{})
test(Test{})
Test{}.test(a)

assert true
}

0 comments on commit d8e1e9d

Please sign in to comment.