You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling the following infers the proper type for T, String:
foo{ bar inbar("Hello")}// Prints "String.Type"
The problem arises when bar is called an additional time within the closure:
foo{ bar in// Error: Generic parameter 'T' could not be inferredbar("Hello")bar("World")}
The only way this issue can be worked around, is by explicitly specifying the type of `bar`:
foo{(bar:(String)->Void)inbar("Hello")bar("World")}// Prints "String.Type"
It seems to me that if Swift can infer the type for the single invocation case, it ought to be able to infer the type for the case with multiple invocations.
The text was updated successfully, but these errors were encountered:
Wildchild9 (JIRA User) Unfortunately this is just a nature of how multi-expression closures are type-checked. The body of the closure is not type-checked together with a call to `foo` so in order to resolve any generic parameters either only parameters or whole type has to be specified explicitly.
Environment
Tested on Xcode Version 11.3.1 (11C504) and Xcode Version 11.4 beta 3 (11N132i).
Additional Detail from JIRA
md5: 6fe608cbd121adcea05965fde2b18fc8
Issue Description:
Let's say I have the following function:
Calling the following infers the proper type for
T
,String
:The problem arises when
bar
is called an additional time within the closure:The only way this issue can be worked around, is by explicitly specifying the type of `bar`:
It seems to me that if Swift can infer the type for the single invocation case, it ought to be able to infer the type for the case with multiple invocations.
The text was updated successfully, but these errors were encountered: