[SR-10767] Generic type inference inconsistency & specificity issue when return value is optional or not. #53157
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
type checker
Area → compiler: Semantic analysis
Additional Detail from JIRA
md5: 59d97d497440eda28dff06be3f28f0ab
Issue Description:
In the following example, `X` resolves to the (more specific) argument type when the function's return type is non-optional but resolves to the (less specific) return type when the function's return type is optional.
The rational for this is unclear and the behaviour appears to be an inconsistency.
Furthermore, it is unclear why f1 would opt to resolve X against the subtype B when the more generic type A is sufficient to solve the type constraints. Resolving X against B needlessly narrows the return type when the function should be perfectly capable of returning any more generic type-A instance.
The text was updated successfully, but these errors were encountered: