Skip to content

Clean up buildBlock(_:) overloads. #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions Sources/VariadicsGenerator/VariadicsGenerator.swift
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,6 @@ struct VariadicsGenerator: ParsableCommand {

""")

print("Generating 'buildBlock(_:)' overloads...", to: &standardError)
for arity in 1..<maxArity {
print(" Capture arity: \(arity)", to: &standardError)
emitUnaryBuildBlock(arity: arity)
}

print("Generating concatenation overloads...", to: &standardError)
for (leftArity, rightArity) in Permutations(totalArity: maxArity) {
guard rightArity != 0 else {
Expand Down Expand Up @@ -195,21 +189,6 @@ struct VariadicsGenerator: ParsableCommand {
return "(\(genericParameters()))"
}

func emitUnaryBuildBlock(arity: Int) {
assert(arity > 0)
let captureTypes = (0..<arity).map { "C\($0)" }.joined(separator: ", ")
output("""
extension RegexBuilder {
public static func buildBlock<R: RegexProtocol, W, \(captureTypes)>(_ regex: R) -> R
where R.Match == (W, \(captureTypes))
{
regex
}
}

""")
}

func emitConcatenation(leftArity: Int, rightArity: Int) {
let genericParams: String = {
var result = "W0, W1"
Expand Down Expand Up @@ -255,7 +234,6 @@ struct VariadicsGenerator: ParsableCommand {
// Emit concatenation builder.
output("extension \(patternBuilderTypeName) {\n")
output("""
@_disfavoredOverload
public static func buildBlock<\(genericParams)>(
combining next: R1, into combined: R0
) -> \(regexTypeName)<\(matchType)> \(whereClause) {
Expand All @@ -270,7 +248,6 @@ struct VariadicsGenerator: ParsableCommand {
// T + () = T
output("""
extension RegexBuilder {
@_disfavoredOverload
public static func buildBlock<W0
""")
outputForEach(0..<leftArity) {
Expand Down
Loading