-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfregressionswift 5.0
Description
| Previous ID | SR-9753 |
| Radar | rdar://problem/47550780 |
| Original Reporter | @lilyball |
| Type | Bug |
| Status | Closed |
| Resolution | Won't Do |
Environment
Apple Swift version 5.0 (swiftlang-1001.0.45.7 clang-1001.0.37.7)
Target: x86_64-apple-darwin18.2.0
ABI version: 0.6
Additional Detail from JIRA
| Votes | 0 |
| Component/s | Compiler |
| Labels | Bug, 5.0Regression |
| Assignee | None |
| Priority | Medium |
md5: d9e050beffdbe60baf098d7a78e86171
Issue Description:
I have a generic struct that declares a method, and an extension to this struct that overloads the method in the case where the generic parameter conforms to Error. This has worked fine so far, but the Swift 5 compiler rejects this as an ambiguity error. It seems to be special-casing Error somehow because this doesn't happen with other protocols. This compiler error happens even in Swift 4 mode (though I don't believe it should happen in Swift 5 mode either).
This error means Xcode 10.2 cannot compile https://github.com/lilyball/Tomorrowland.
struct Foo<E> {
func bar(with: Foo<E>) {}
}
extension Foo where E: Error {
func bar(with: Foo<Error>) {}
}
let foo = Foo<Error>()
foo.bar(with: Foo<Error>())This yields
unnamed.swift:10:1: error: ambiguous use of 'bar(with:)'
foo.bar(with: Foo<Error>())
^
unnamed.swift:2:10: note: found this candidate
func bar(with: Foo<E>) {}
^
unnamed.swift:6:10: note: found this candidate
func bar(with: Foo<Error>) {}
^
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfregressionswift 5.0