Skip to content

Commit 1b5036a

Browse files
jmschonfeldchloe-yeo
authored andcommitted
(157858997) Cleanup FoundationMacros availability checks (#1469)
1 parent a787b71 commit 1b5036a

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

Tests/FoundationMacrosTests/MacroTestUtilities.swift

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ struct DiagnosticTest : ExpressibleByStringLiteral, Hashable, CustomStringConver
4747

4848
var mappedToExpression: Self {
4949
DiagnosticTest(
50-
message._replacing("Predicate", with: "Expression")._replacing("predicate", with: "expression"),
50+
message.replacing("Predicate", with: "Expression").replacing("predicate", with: "expression"),
5151
fixIts: fixIts.map {
52-
FixItTest($0.message, result: $0.result._replacing("#Predicate", with: "#Expression"))
52+
FixItTest($0.message, result: $0.result.replacing("#Predicate", with: "#Expression"))
5353
}
5454
)
5555
}
@@ -100,7 +100,7 @@ extension Diagnostic {
100100
} else {
101101
var result = "Message: \(debugDescription)\nFix-Its:\n"
102102
for fixIt in fixIts {
103-
result += "\t\(fixIt.message.message)\n\t\(fixIt.changes.first!._result._replacing("\n", with: "\n\t"))"
103+
result += "\t\(fixIt.message.message)\n\t\(fixIt.changes.first!._result.replacing("\n", with: "\n\t"))"
104104
}
105105
return result
106106
}
@@ -114,7 +114,7 @@ extension DiagnosticTest {
114114
} else {
115115
var result = "Message: \(message)\nFix-Its:\n"
116116
for fixIt in fixIts {
117-
result += "\t\(fixIt.message)\n\t\(fixIt.result._replacing("\n", with: "\n\t"))"
117+
result += "\t\(fixIt.message)\n\t\(fixIt.result.replacing("\n", with: "\n\t"))"
118118
}
119119
return result
120120
}
@@ -164,21 +164,9 @@ func AssertPredicateExpansion(_ source: String, _ result: String = "", diagnosti
164164
)
165165
AssertMacroExpansion(
166166
macros: ["Expression" : FoundationMacros.ExpressionMacro.self],
167-
source._replacing("#Predicate", with: "#Expression"),
168-
result._replacing(".Predicate", with: ".Expression"),
167+
source.replacing("#Predicate", with: "#Expression"),
168+
result.replacing(".Predicate", with: ".Expression"),
169169
diagnostics: Set(diagnostics.map(\.mappedToExpression)),
170170
sourceLocation: sourceLocation
171171
)
172172
}
173-
174-
extension String {
175-
func _replacing(_ text: String, with other: String) -> Self {
176-
if #available(macOS 13.0, *) {
177-
// Use the stdlib API if available
178-
self.replacing(text, with: other)
179-
} else {
180-
// Use the Foundation API on older OSes
181-
self.replacingOccurrences(of: text, with: other, options: [.literal])
182-
}
183-
}
184-
}

Tests/FoundationMacrosTests/PredicateMacroUsageTests.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,12 @@ import Foundation
2121
fileprivate func _blackHole<T>(_ t: T) {}
2222

2323
@inline(never)
24-
@available(macOS 14, iOS 17, watchOS 10, tvOS 17, *)
2524
fileprivate func _blackHoleExplicitInput(_ predicate: Predicate<Int>) {}
2625

2726
// MARK: - Tests
2827

2928
@Suite("#Predicate Macro Usage")
3029
private struct PredicateMacroUsageTests {
31-
@available(macOS 14, iOS 17, watchOS 10, tvOS 17, *)
3230
@Test func usage() {
3331
_blackHole(#Predicate<Bool> {
3432
return $0

0 commit comments

Comments
 (0)