Skip to content

Commit 316475c

Browse files
authored
Merge pull request #33564 from DougGregor/function-builders-remove-build-do
2 parents 5c4c4dc + 9ffddc9 commit 316475c

File tree

3 files changed

+3
-30
lines changed

3 files changed

+3
-30
lines changed

include/swift/AST/KnownIdentifiers.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ IDENTIFIER(atIndexedSubscript)
3333
IDENTIFIER_(bridgeToObjectiveC)
3434
IDENTIFIER(buildArray)
3535
IDENTIFIER(buildBlock)
36-
IDENTIFIER(buildDo)
3736
IDENTIFIER(buildEither)
3837
IDENTIFIER(buildExpression)
3938
IDENTIFIER(buildFinalResult)

lib/Sema/BuilderTransform.cpp

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -310,10 +310,6 @@ class BuilderClosureVisitor
310310
}
311311

312312
VarDecl *visitBraceStmt(BraceStmt *braceStmt) {
313-
return visitBraceStmt(braceStmt, ctx.Id_buildBlock);
314-
}
315-
316-
VarDecl *visitBraceStmt(BraceStmt *braceStmt, Identifier builderFunction) {
317313
SmallVector<Expr *, 4> expressions;
318314
auto addChild = [&](VarDecl *childVar) {
319315
if (!childVar)
@@ -380,7 +376,7 @@ class BuilderClosureVisitor
380376

381377
// Call Builder.buildBlock(... args ...)
382378
auto call = buildCallIfWanted(braceStmt->getStartLoc(),
383-
builderFunction, expressions,
379+
ctx.Id_buildBlock, expressions,
384380
/*argLabels=*/{ });
385381
if (!call)
386382
return nullptr;
@@ -395,13 +391,7 @@ class BuilderClosureVisitor
395391
}
396392

397393
VarDecl *visitDoStmt(DoStmt *doStmt) {
398-
if (!builderSupports(ctx.Id_buildDo)) {
399-
if (!unhandledNode)
400-
unhandledNode = doStmt;
401-
return nullptr;
402-
}
403-
404-
auto childVar = visitBraceStmt(doStmt->getBody(), ctx.Id_buildDo);
394+
auto childVar = visitBraceStmt(doStmt->getBody());
405395
if (!childVar)
406396
return nullptr;
407397

test/Constraints/function_builder.swift

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@ struct TupleBuilder {
3636
return (t1, t2, t3, t4, t5)
3737
}
3838

39-
static func buildDo<T1>(_ t1: T1) -> Do<(T1)> {
40-
.init(value: t1)
41-
}
42-
43-
static func buildDo<T1, T2>(_ t1: T1, _ t2: T2) -> Do<(T1, T2)> {
44-
.init(value: (t1, t2))
45-
}
46-
47-
static func buildDo<T1, T2, T3>(_ t1: T1, _ t2: T2, _ t3: T3)
48-
-> Do<(T1, T2, T3)> {
49-
.init(value: (t1, t2, t3))
50-
}
51-
5239
static func buildIf<T>(_ value: T?) -> T? { return value }
5340

5441
static func buildEither<T,U>(first value: T) -> Either<T,U> {
@@ -65,7 +52,7 @@ func tuplify<T>(_ cond: Bool, @TupleBuilder body: (Bool) -> T) {
6552
print(body(cond))
6653
}
6754

68-
// CHECK: (17, 3.14159, "Hello, DSL", main.Do<(Swift.Array<Swift.String>, Swift.Int)>(value: (["nested", "do"], 6)), Optional((2.71828, ["if", "stmt"])))
55+
// CHECK: (17, 3.14159, "Hello, DSL", (["nested", "do"], 6), Optional((2.71828, ["if", "stmt"])))
6956
let name = "dsl"
7057
tuplify(true) {
7158
17
@@ -664,7 +651,6 @@ struct TupleBuilderWithOpt {
664651
return (t1, t2, t3, t4, t5)
665652
}
666653

667-
static func buildDo<T>(_ value: T) -> T { return value }
668654
static func buildOptional<T>(_ value: T?) -> T? { return value }
669655

670656
static func buildEither<T,U>(first value: T) -> Either<T,U> {
@@ -718,7 +704,6 @@ protocol FunctionBuilderProtocol {
718704

719705
static func buildExpression(_ expression: Expression) -> Component
720706
static func buildBlock(_ components: Component...) -> Component
721-
static func buildDo(_ components: Component...) -> Component
722707
static func buildOptional(_ optional: Component?) -> Component
723708
static func buildArray(_ components: [Component]) -> Component
724709
static func buildLimitedAvailability(_ component: Component) -> Component
@@ -729,7 +714,6 @@ protocol FunctionBuilderProtocol {
729714
extension FunctionBuilderProtocol {
730715
static func buildExpression(_ expression: Expression) -> Component { .expression(expression) }
731716
static func buildBlock(_ components: Component...) -> Component { .block(components) }
732-
static func buildDo(_ components: Component...) -> Component { .block(components) }
733717
static func buildOptional(_ optional: Component?) -> Component { .optional(optional) }
734718
static func buildArray(_ components: [Component]) -> Component { .block(components) }
735719
static func buildLimitedAvailability(_ component: Component) -> Component { component }

0 commit comments

Comments
 (0)