diff --git a/vlib/v/ast/table.v b/vlib/v/ast/table.v index ed582f54c5..bb30ef0cda 100644 --- a/vlib/v/ast/table.v +++ b/vlib/v/ast/table.v @@ -1121,6 +1121,12 @@ pub fn (mut t Table) does_type_implement_interface(typ Type, inter_typ Type) boo if typ_sym.language != .v { return false } + // generic struct don't generate cast interface fn + if typ_sym.info is Struct { + if typ_sym.info.is_generic { + return false + } + } mut inter_sym := t.get_type_symbol(inter_typ) if typ_sym.kind == .interface_ && inter_sym.kind == .interface_ { return false diff --git a/vlib/v/tests/generics_interface_decl_test.v b/vlib/v/tests/generics_interface_decl_test.v new file mode 100644 index 0000000000..e96aa8dcb6 --- /dev/null +++ b/vlib/v/tests/generics_interface_decl_test.v @@ -0,0 +1,23 @@ +interface Depends { + depends() []Depends +} + +struct Signal { +} + +fn (x Signal) depends() []Depends { + return [] +} + +struct Add { + a Signal + b Signal +} + +fn (a Add) depends() []Depends { + return [a.a, a.b] +} + +fn test_generics_interface_decl() { + assert true +}