1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

checker: fix generic struct with non-generic interface in generic fn (#11252)

This commit is contained in:
yuyi 2021-08-20 14:28:26 +08:00 committed by GitHub
parent 4fb570522a
commit 6201e78201
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -731,6 +731,11 @@ fn (mut c Checker) unwrap_generic_type(typ ast.Type, generic_names []string, con
final_concrete_types << t_typ
}
}
if final_concrete_types.len > 0 {
for method in ts.methods {
c.table.register_fn_concrete_types(method.name, final_concrete_types)
}
}
}
}
else {}

View File

@ -23,3 +23,17 @@ fn test_generic_struct_with_non_generic_interface() {
println(ret)
assert ret == 106
}
fn run<T>(data T) {
t := Test<T>{
data: data
salt: 6
}
x := box_transform(t)
println(x)
assert x == 106
}
fn test_generic_struct_with_non_generic_interface_in_generic_fn() {
run('foo')
}