Skip to content

Commit fe5be63

Browse files
authored
Merge pull request #34772 from slavapestov/fix-lazy-getter-source-range
Sema: Fix source range of 'lazy' property getter
2 parents 9a510b8 + 756357b commit fe5be63

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/Sema/TypeCheckStorage.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,8 @@ synthesizeLazyGetterBody(AccessorDecl *Get, VarDecl *VD, VarDecl *Storage,
13621362

13631363
Body.push_back(new (Ctx) ReturnStmt(SourceLoc(), Tmp2DRE, /*implicit*/true));
13641364

1365-
return { BraceStmt::create(Ctx, VD->getLoc(), Body, VD->getLoc(),
1365+
auto Range = InitValue->getSourceRange();
1366+
return { BraceStmt::create(Ctx, Range.Start, Body, Range.End,
13661367
/*implicit*/true),
13671368
/*isTypeChecked=*/true };
13681369
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %target-swift-frontend -emit-ir %s
2+
3+
struct Horse {}
4+
5+
class Reproducer {
6+
lazy var barn: Any = {
7+
class Barn {
8+
var horse: Horse {
9+
return Horse()
10+
}
11+
}
12+
return Barn()
13+
}()
14+
}
15+

0 commit comments

Comments
 (0)