Skip to content

Commit 5b7f21f

Browse files
authored
Merge pull request swiftlang#25917 from rjmccall/pound-if-function-builders
Allow #if in function builders.
2 parents 88f8a3c + d975e8a commit 5b7f21f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ class BuilderClosureVisitor
136136
}
137137

138138
if (auto decl = node.dyn_cast<Decl *>()) {
139+
// Just ignore #if; the chosen children should appear in the
140+
// surrounding context. This isn't good for source tools but it
141+
// at least works.
142+
if (isa<IfConfigDecl>(decl))
143+
continue;
144+
139145
if (!unhandledNode)
140146
unhandledNode = decl;
141147

test/Constraints/function_builder.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ tuplify(true) {
149149
}
150150
}
151151

152+
// rdar://50710698
153+
// CHECK: ("chain5", 8, 9)
154+
tuplify(true) {
155+
"chain5"
156+
#if false
157+
6
158+
$0
159+
#else
160+
8
161+
9
162+
#endif
163+
}
164+
152165
// CHECK: ("getterBuilder", 0, 4, 12)
153166
@TupleBuilder
154167
var globalBuilder: (String, Int, Int, Int) {

0 commit comments

Comments
 (0)