Skip to content

Commit ed8b7cc

Browse files
committed
Revert "Merge pull request swiftlang#628 from apple/result_builder_changes_workaround"
This reverts commit 7e059b7, reversing changes made to 3ca8b13.
1 parent 7756942 commit ed8b7cc

File tree

4 files changed

+23
-29
lines changed

4 files changed

+23
-29
lines changed

Sources/_StringProcessing/MatchingOptions.swift

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414
/// A type that represents the current state of regex matching options, with
1515
/// stack-based scoping.
1616
struct MatchingOptions {
17-
// FIXME: Workaround for rdar://104923020
18-
// fileprivate
19-
var stack: [Representation]
17+
fileprivate var stack: [Representation]
2018

2119
fileprivate func _invariantCheck() {
2220
assert(!stack.isEmpty, "Unbalanced call to endScope")
@@ -127,9 +125,7 @@ extension MatchingOptions {
127125
// MARK: - Implementation
128126
extension MatchingOptions {
129127
/// An option that changes the behavior of a regular expression.
130-
// FIXME: Workaround for rdar://104923020
131-
// fileprivate
132-
enum Option: Int {
128+
fileprivate enum Option: Int {
133129
// PCRE options
134130
case caseInsensitive
135131
case allowDuplicateGroupNames
@@ -216,9 +212,7 @@ extension MatchingOptions {
216212

217213
extension MatchingOptions {
218214
/// A set of matching options.
219-
// FIXME: Workaround for rdar://104923020
220-
// fileprivate
221-
struct Representation: OptionSet, RawRepresentable {
215+
fileprivate struct Representation: OptionSet, RawRepresentable {
222216
var rawValue: UInt32
223217

224218
/// Returns `true` if the option denoted by `kind` is a member of this set.

Tests/RegexBuilderTests/CustomTests.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class CustomRegexComponentTests: XCTestCase {
226226
// tests.
227227
func testCustomRegexComponents() throws {
228228
customTest(
229-
Regex<Substring> {
229+
Regex {
230230
Numbler()
231231
Asciibbler()
232232
},
@@ -237,7 +237,7 @@ class CustomRegexComponentTests: XCTestCase {
237237
("t4", .match, nil))
238238

239239
customTest(
240-
Regex<Substring> {
240+
Regex {
241241
OneOrMore { Numbler() }
242242
},
243243
("ab123c", .firstMatch, "123"),
@@ -520,7 +520,7 @@ class CustomRegexComponentTests: XCTestCase {
520520
)
521521

522522
customTest(
523-
Regex<CurrencyParser.Currency> {
523+
Regex {
524524
CurrencyParser()
525525
},
526526
("USD", .usd, nil),
@@ -532,7 +532,7 @@ class CustomRegexComponentTests: XCTestCase {
532532

533533
// No capture, two errors
534534
customTest(
535-
Regex<Substring> {
535+
Regex {
536536
IntParser()
537537
" "
538538
IntParser()
@@ -544,7 +544,7 @@ class CustomRegexComponentTests: XCTestCase {
544544
)
545545

546546
customTest(
547-
Regex<Substring> {
547+
Regex {
548548
CurrencyParser()
549549
IntParser()
550550
},
@@ -557,7 +557,7 @@ class CustomRegexComponentTests: XCTestCase {
557557
// One capture, two errors: One error is thrown from inside a capture,
558558
// while the other one is thrown from outside
559559
customTest(
560-
Regex<(Substring, CurrencyParser.Currency)> {
560+
Regex {
561561
Capture { CurrencyParser() }
562562
IntParser()
563563
},
@@ -568,7 +568,7 @@ class CustomRegexComponentTests: XCTestCase {
568568
)
569569

570570
customTest(
571-
Regex<(Substring, Int)> {
571+
Regex {
572572
CurrencyParser()
573573
Capture { IntParser() }
574574
},
@@ -580,7 +580,7 @@ class CustomRegexComponentTests: XCTestCase {
580580

581581
// One capture, two errors: Both errors are thrown from inside the capture
582582
customTest(
583-
Regex<(Substring, Substring)> {
583+
Regex {
584584
Capture {
585585
CurrencyParser()
586586
IntParser()
@@ -594,7 +594,7 @@ class CustomRegexComponentTests: XCTestCase {
594594

595595
// Two captures, two errors: Different erros are thrown from inside captures
596596
customTest(
597-
Regex<(Substring, CurrencyParser.Currency, Int)> {
597+
Regex {
598598
Capture(CurrencyParser())
599599
Capture(IntParser())
600600
},

Tests/RegexBuilderTests/MotivationTests.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,8 @@ extension RegexDSLTests {
310310
"CREDIT"
311311
"DEBIT"
312312
}
313-
} transform: { (s: Substring) -> TransactionKind? in
314-
TransactionKind(rawValue: String(s))
313+
} transform: {
314+
TransactionKind(rawValue: String($0))
315315
}
316316

317317
OneOrMore(.whitespace)
@@ -323,8 +323,8 @@ extension RegexDSLTests {
323323
Repeat(.digit, count: 2)
324324
Repeat(.digit, count: 2)
325325
Repeat(.digit, count: 4)
326-
} transform: { (s: Substring) -> Date? in
327-
Date(mmddyyyy: String(s))
326+
} transform: {
327+
Date(mmddyyyy: String($0))
328328
}
329329

330330
OneOrMore(.whitespace)
@@ -346,8 +346,8 @@ extension RegexDSLTests {
346346
OneOrMore(.digit)
347347
"."
348348
Repeat(.digit, count: 2)
349-
} transform: { (s: Substring) -> Double? in
350-
Double(s)
349+
} transform: {
350+
Double($0)
351351
}
352352
}
353353

Tests/RegexBuilderTests/RegexDSLTests.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1254,8 +1254,8 @@ class RegexDSLTests: XCTestCase {
12541254
TryCapture(as: b) {
12551255
"#"
12561256
OneOrMore(.digit)
1257-
} transform: { (s: Substring) in
1258-
Int(s.dropFirst())
1257+
} transform: {
1258+
Int($0.dropFirst())
12591259
}
12601260
}
12611261
a
@@ -1272,14 +1272,14 @@ class RegexDSLTests: XCTestCase {
12721272
do {
12731273
let a = Reference(Substring.self)
12741274
let b = Reference(Int.self)
1275-
let regex = Regex<(Substring, Substring, Int?, Int?, Substring?)> {
1275+
let regex = Regex {
12761276
Capture("abc", as: a)
12771277
ZeroOrMore {
12781278
TryCapture(as: b) {
12791279
"#"
12801280
OneOrMore(.digit)
1281-
} transform: { (s: Substring) -> Int? in
1282-
Int(s.dropFirst())
1281+
} transform: {
1282+
Int($0.dropFirst())
12831283
}
12841284
}
12851285
a

0 commit comments

Comments
 (0)