Skip to content

Commit f28f709

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 03f19fe commit f28f709

File tree

2 files changed

+0
-151
lines changed

2 files changed

+0
-151
lines changed

Sources/VariadicsGenerator/VariadicsGenerator.swift

Lines changed: 0 additions & 23 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
let genericParams: String = {
215194
var result = "W0, W1"
@@ -255,7 +234,6 @@ struct VariadicsGenerator: ParsableCommand {
255234
// Emit concatenation builder.
256235
output("extension \(patternBuilderTypeName) {\n")
257236
output("""
258-
@_disfavoredOverload
259237
public static func buildBlock<\(genericParams)>(
260238
combining next: R1, into combined: R0
261239
) -> \(regexTypeName)<\(matchType)> \(whereClause) {
@@ -270,7 +248,6 @@ struct VariadicsGenerator: ParsableCommand {
270248
// T + () = T
271249
output("""
272250
extension RegexBuilder {
273-
@_disfavoredOverload
274251
public static func buildBlock<W0
275252
""")
276253
outputForEach(0..<leftArity) {

0 commit comments

Comments
 (0)