Skip to content

Commit 5195e89

Browse files
authored
Merge pull request #82792 from xedin/rdar-154719565-workaround-with-disfavored
[SwiftCompilerSources] Disfavor overload of `==` that takes `StringRef`
2 parents c06951e + e3a5477 commit 5195e89

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

SwiftCompilerSources/Sources/Basic/Utils.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,10 @@ public struct StringRef : CustomStringConvertible, NoReflectionChildren, Express
110110
}
111111
}
112112

113+
/// This overload is disfavored to make sure that it's only used for cases that don't involve literals, for that
114+
/// `==(StringRef, StaticString) -> Bool` is preferred. Otherwise these overloads are
115+
/// going to be ambiguous because both StringRef, StaticString conform to `ExpressibleByStringLiteral`.
116+
@_disfavoredOverload
113117
public static func ==(lhs: StringRef, rhs: StringRef) -> Bool {
114118
let lhsBuffer = UnsafeBufferPointer<UInt8>(start: lhs._bridged.data, count: lhs.count)
115119
let rhsBuffer = UnsafeBufferPointer<UInt8>(start: rhs._bridged.data, count: rhs.count)

0 commit comments

Comments
 (0)