diff --git a/vlib/v/checker/fn.v b/vlib/v/checker/fn.v index 7b064d8968..b024a9716e 100644 --- a/vlib/v/checker/fn.v +++ b/vlib/v/checker/fn.v @@ -1369,6 +1369,13 @@ pub fn (mut c Checker) method_call(mut node ast.CallExpr) ast.Type { node.concrete_list_pos) } if method.generic_names.len > 0 { + if !left_type.has_flag(.generic) { + if left_sym.info is ast.Struct { + if method.generic_names.len == left_sym.info.concrete_types.len { + node.concrete_types = left_sym.info.concrete_types + } + } + } return node.return_type } return method.return_type diff --git a/vlib/v/tests/generics_struct_inst_method_call_test.v b/vlib/v/tests/generics_struct_inst_method_call_test.v new file mode 100644 index 0000000000..76694a7b8e --- /dev/null +++ b/vlib/v/tests/generics_struct_inst_method_call_test.v @@ -0,0 +1,29 @@ +fn test_generics_struct_inst_method_call() { + v1 := V2d{100} + r1 := v1.in_bounds(tp_lft, bt_rigt) + println(r1) + assert r1 +} + +const ( + tp_lft = V2d{20} + bt_rigt = V2d{650} +) + +struct V2d { +mut: + x T +} + +pub fn (v1 V2d) unpack() T { + return v1.x +} + +pub fn (v1 V2d) less_than(v2 V2d) V2d { + return V2d{v1.x < v2.x} +} + +pub fn (v1 V2d) in_bounds(top_left V2d, bottom_right V2d) bool { + v1.less_than(bottom_right).unpack() + return true +}