table: fix error of generics interface declaration (#10883)

pull/10894/head
yuyi 2021-07-21 20:24:52 +08:00 committed by GitHub
parent e38b0d7e9f
commit ec87f4ee99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,23 @@
interface Depends {
depends() []Depends
}
struct Signal<T> {
}
fn (x Signal<T>) depends() []Depends {
return []
}
struct Add<T> {
a Signal<T>
b Signal<T>
}
fn (a Add<T>) depends() []Depends {
return [a.a, a.b]
}
fn test_generics_interface_decl() {
assert true
}