diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 53ab2905c62c7f..96d72ed4ad39a2 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -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 } diff --git a/vlib/v/tests/iface_arg_test.v b/vlib/v/tests/iface_arg_test.v index cf4b7e6fc0f1c1..9405918744b4f5 100644 --- a/vlib/v/tests/iface_arg_test.v +++ b/vlib/v/tests/iface_arg_test.v @@ -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 +}