-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Closed
Copy link
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 itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Previous ID | SR-12459 |
Radar | rdar://problem/62202443 |
Original Reporter | @ahoppen |
Type | Bug |
Status | Resolved |
Resolution | Done |
Additional Detail from JIRA
Votes | 0 |
Component/s | Compiler |
Labels | Bug, DiagnosticsQoI, TypeChecker |
Assignee | @ahoppen |
Priority | Medium |
md5: 886bc3d5b61b666595f45872e20f5f63
Issue Description:
Take a look at the following code:
protocol Foo {}
extension Foo {
static func ==(lhs: Foo, rhs: Foo) -> Bool {
fatalError()
}
}
struct Bar: Foo {}
let a: Foo = Bar()
let b: Foo = Bar()
print(a == b) // Error: Binary operator '==' cannot be applied to two 'Foo' operands
I would expect a == b
to call the ==
operator declared in the extension of Foo
. However, I get an error „Binary operator '==' cannot be applied to two 'Foo' operands“.
Using Swift 5.2 shipped with Xcode 11.4 (11E146, swiftlang-1103.0.32.1)
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 itselfdiagnostics QoIBug: Diagnostics Quality of ImplementationBug: Diagnostics Quality of Implementationtype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis