[SR-1789] Swift can't infer types in generic methods that reuse part of the struct/class' parameters #44398
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
feature
A feature request or implementation
type checker
Area → compiler: Semantic analysis
Additional Detail from JIRA
md5: 0101359cc12f70fff9f02db7121d39ee
is duplicated by:
relates to:
Issue Description:
The following code fails because Swift can't infer the types:
Running this results in the following type error:
What I Expected
Given that the return value for the generic type says `Product<C, B>`, that's what I would have expected Swift to infer the type as, in which case the code should type check. But instead Swift is inferring it as `Product<A, B>`.
A different❓ type inference error occurs when you have a tuple for the values there instead of the values in separated fields. In this case, Swift infers the tuple to be `(_, _)`.
In both cases I expected the code to type check correctly.
The text was updated successfully, but these errors were encountered: