swift
e3a5477b - [SwiftCompilerSources] Disfavor overload of `==` that takes `StringRef`

Commit
234 days ago
[SwiftCompilerSources] Disfavor overload of `==` that takes `StringRef` This overload is disfavored to make sure that it's only used for cases that don't involve literals, for that `==(StringRef, StaticString) -> Bool` is preferred. Otherwise these overloads are going to be ambiguous because both `StringRef`, `StaticString` conform to `ExpressibleByStringLiteral`. Consider the following example: ```swift func test(lhs: StringRef) { lhs == "<<test>>" } ``` The type-checker used to pick `==(StringRef, StringRef)` overload in this case because it has homogenous parameter types but this is no longer the case because this behavior was too aggressive and led to sub-optimal choices by completely skipping other viable overloads. Since `StaticString` already represents literals it's better to use a standard library type and reserve the `(StringRef, StringRef)` overload to when the literals are not involved. Resolves: rdar://154719565
Author
Parents
Loading