Commit e3a5477
committed
[SwiftCompilerSources] Disfavor overload of
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== that takes StringRef
1 parent 576a378 commit e3a5477
1 file changed
+4
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
113 | 117 | | |
114 | 118 | | |
115 | 119 | | |
| |||
0 commit comments