File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -1275,7 +1275,7 @@ class ResultBuilderTransform
1275
1275
// The operand should have optional type if we had optional results,
1276
1276
// so we just need to call `buildIf` now, since we're at the top level.
1277
1277
if (isOptional && isTopLevel (anchor)) {
1278
- builderCall = buildCallIfWanted (ifStmt->getEndLoc (),
1278
+ builderCall = buildCallIfWanted (ifStmt->getThenStmt ()-> getStartLoc (),
1279
1279
builder.getBuildOptionalId (),
1280
1280
builderCall, /* argLabels=*/ {});
1281
1281
}
@@ -1304,7 +1304,7 @@ class ResultBuilderTransform
1304
1304
/* argLabels=*/ {}));
1305
1305
}
1306
1306
1307
- auto *ifVarRef = builder.buildVarRef (ifVar.get (), ifStmt->getEndLoc ());
1307
+ auto *ifVarRef = builder.buildVarRef (ifVar.get (), ifStmt->getStartLoc ());
1308
1308
doBody.push_back (TypeJoinExpr::create (ctx, ifVarRef, buildEitherCalls));
1309
1309
}
1310
1310
Original file line number Diff line number Diff line change
1
+ // RUN: %sourcekitd-test -req=collect-type %s -- %s
2
+
3
+ struct Rectangle {
4
+ init ( ) { }
5
+ }
6
+
7
+ @resultBuilder public struct WiewBuilder {
8
+ public static func buildBlock< Content> ( _ content: Content ) -> Content {
9
+ return content
10
+ }
11
+ public static func buildIf< Content> ( _ content: Content ? ) -> Content ? {
12
+ return content
13
+ }
14
+ }
15
+
16
+ public struct AStack < Content> {
17
+ init ( @WiewBuilder content: ( ) -> Content ) { }
18
+ }
19
+
20
+ func foo( ) {
21
+ AStack {
22
+ if true {
23
+ Rectangle ( )
You can’t perform that action at this time.
0 commit comments