mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
This commit is contained in:
parent
a647a71c52
commit
5e12d3483c
@ -1354,13 +1354,23 @@ fn (mut c Checker) fn_call(mut node ast.CallExpr, mut continue_check &bool) ast.
|
||||
}
|
||||
}
|
||||
return node.return_type
|
||||
} else if typ := c.table.resolve_generic_to_concrete(func.return_type, func.generic_names,
|
||||
concrete_types)
|
||||
{
|
||||
if typ.has_flag(.generic) {
|
||||
node.return_type = typ
|
||||
} else {
|
||||
if node.concrete_types.len > 0 && !node.concrete_types.any(it.has_flag(.generic)) {
|
||||
if typ := c.table.resolve_generic_to_concrete(func.return_type, func.generic_names,
|
||||
node.concrete_types)
|
||||
{
|
||||
node.return_type = typ
|
||||
return typ
|
||||
}
|
||||
}
|
||||
if typ := c.table.resolve_generic_to_concrete(func.return_type, func.generic_names,
|
||||
concrete_types)
|
||||
{
|
||||
if typ.has_flag(.generic) {
|
||||
node.return_type = typ
|
||||
}
|
||||
return typ
|
||||
}
|
||||
return typ
|
||||
}
|
||||
}
|
||||
return func.return_type
|
||||
|
14
vlib/v/tests/generic_fn_with_nested_generic_fn_call_test.v
Normal file
14
vlib/v/tests/generic_fn_with_nested_generic_fn_call_test.v
Normal file
@ -0,0 +1,14 @@
|
||||
struct Test {}
|
||||
|
||||
fn unmarshal[T]() ! {
|
||||
get_number[int]()!
|
||||
}
|
||||
|
||||
fn get_number[T]() !T {
|
||||
return T(42)
|
||||
}
|
||||
|
||||
fn test_generic_fn_with_nested_generic_fn_call() {
|
||||
unmarshal[Test]()!
|
||||
assert true
|
||||
}
|
Loading…
Reference in New Issue
Block a user