Skip to content

Commit a78d641

Browse files
committed
Clean up buildBlock(_:) overloads.
- Remove 9 unused `RegexBuilder.buildBlock(_:)` overloads. - Remove useless `@_disfavoredOverload`. `@_disfavoredOverload` is only useful for matching nullary captures when there are overloads for n-ary captures.
1 parent 883d358 commit a78d641

File tree

2 files changed

+271
-422
lines changed

2 files changed

+271
-422
lines changed

Sources/VariadicsGenerator/VariadicsGenerator.swift

Lines changed: 5 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,6 @@ struct VariadicsGenerator: ParsableCommand {
127127
128128
""")
129129

130-
print("Generating 'buildBlock(_:)' overloads...", to: &standardError)
131-
for arity in 1..<maxArity {
132-
print(" Capture arity: \(arity)", to: &standardError)
133-
emitUnaryBuildBlock(arity: arity)
134-
}
135-
136130
print("Generating concatenation overloads...", to: &standardError)
137131
for (leftArity, rightArity) in Permutations(totalArity: maxArity) {
138132
guard rightArity != 0 else {
@@ -195,21 +189,6 @@ struct VariadicsGenerator: ParsableCommand {
195189
return "(\(genericParameters()))"
196190
}
197191

198-
func emitUnaryBuildBlock(arity: Int) {
199-
assert(arity > 0)
200-
let captureTypes = (0..<arity).map { "C\($0)" }.joined(separator: ", ")
201-
output("""
202-
extension RegexBuilder {
203-
public static func buildBlock<R: RegexProtocol, W, \(captureTypes)>(_ regex: R) -> R
204-
where R.Match == (W, \(captureTypes))
205-
{
206-
regex
207-
}
208-
}
209-
210-
""")
211-
}
212-
213192
func emitConcatenation(leftArity: Int, rightArity: Int) {
214193
func genericParameters(withConstraints: Bool) -> String {
215194
var result = "W0, W1"
@@ -260,13 +239,12 @@ struct VariadicsGenerator: ParsableCommand {
260239
// Emit concatenation builder.
261240
output("extension \(patternBuilderTypeName) {\n")
262241
output("""
263-
@_disfavoredOverload
264-
public static func buildBlock<\(genericParameters(withConstraints: true))>(
265-
combining next: R1, into combined: R0
266-
) -> \(regexTypeName)<\(matchType)> \(whereClause) {
267-
.init(node: combined.regex.root.appending(next.regex.root))
268-
}
242+
public static func buildBlock<\(genericParameters(withConstraints: true))>(
243+
combining next: R1, into combined: R0
244+
) -> \(regexTypeName)<\(matchType)> \(whereClause) {
245+
.init(node: combined.regex.root.appending(next.regex.root))
269246
}
247+
}
270248
271249
""")
272250
}
@@ -275,7 +253,6 @@ struct VariadicsGenerator: ParsableCommand {
275253
// T + () = T
276254
output("""
277255
extension RegexBuilder {
278-
@_disfavoredOverload
279256
public static func buildBlock<W0
280257
""")
281258
outputForEach(0..<leftArity) {

0 commit comments

Comments
 (0)