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:
parent
4fb570522a
commit
6201e78201
@ -731,6 +731,11 @@ fn (mut c Checker) unwrap_generic_type(typ ast.Type, generic_names []string, con
|
|||||||
final_concrete_types << t_typ
|
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 {}
|
else {}
|
||||||
|
@ -23,3 +23,17 @@ fn test_generic_struct_with_non_generic_interface() {
|
|||||||
println(ret)
|
println(ret)
|
||||||
assert ret == 106
|
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')
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user