diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index 61032610b2..e74f3afd3d 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -2087,7 +2087,7 @@ pub fn (mut t Table) unwrap_generic_type(typ Type, generic_names []string, concr } } mut info := ts.info - info.is_generic = false + info.is_generic = final_concrete_types.any(it.has_flag(.generic)) info.concrete_types = final_concrete_types info.parent_type = typ.set_flag(.generic) info.fields = fields diff --git a/vlib/v/tests/interface_generic_implements_test.v b/vlib/v/tests/interface_generic_implements_test.v new file mode 100644 index 0000000000..f09f305a6d --- /dev/null +++ b/vlib/v/tests/interface_generic_implements_test.v @@ -0,0 +1,19 @@ +interface Foo[T] { + val T + foo() T +} + +struct Bar[T] implements Foo[T] { + val T +} + +fn (b Bar[T]) foo() T { + return b.val +} + +fn test_main() { + b := Bar{ + val: 0 + } + assert b.foo() == 0 +}