[SR-3873] Overloading of concrete type extension methods does not behave like protocol extension methods. #46458
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
Environment
Xcode 8.3 beta (8W109m)
macOS 10.12.3
Additional Detail from JIRA
md5: 57e0fc1a7bcacf22e75ab63b159d301f
Issue Description:
Concrete type extension methods do not exhibit the same overloading order as protocol extension methods.
Given these types:
We currently have three protocol extension based method overloads:
With the introduction of concrete same-type constraint, ideally we would be able to do:
But the Swift 3.1 compiler complains that:
I was able to workaround it in Swift 3.1 GM by keeping the second and the third overload in the protocol `P`:
As a side note, if I replace the `U` parameter on the methods with `T1` in the protocol extension based version, the compiler would start complaining about ambiguous use of `foo` similarly. IOW, the overloading rules seem to be inconsistent among the presence and absence of generic parameters too.
The text was updated successfully, but these errors were encountered: