Skip to content

Commit f85bb3e

Browse files
authored
Merge pull request #21441 from xedin/fix-lazy-init-expr-csgen
[CodeSynthesis] Make sure that `LazyInitializerExpr` has a type
2 parents 93d6eb9 + 20b7c2a commit f85bb3e

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

lib/Sema/CSApply.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,8 +3885,9 @@ namespace {
38853885
}
38863886

38873887
Expr *visitLazyInitializerExpr(LazyInitializerExpr *expr) {
3888-
simplifyExprType(expr);
3889-
assert(expr->getType()->isEqual(expr->getSubExpr()->getType()));
3888+
// Since `LazyInitializerExpr` should always have a type set,
3889+
// there is no need to do anything here.
3890+
assert(cs.getType(expr)->isEqual(expr->getSubExpr()->getType()));
38903891
return expr;
38913892
}
38923893

lib/Sema/CSGen.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2918,7 +2918,9 @@ namespace {
29182918
}
29192919

29202920
Type visitLazyInitializerExpr(LazyInitializerExpr *expr) {
2921-
return expr->getType();
2921+
auto type = expr->getType();
2922+
assert(type && "LazyInitializerExpr should always have type set");
2923+
return type;
29222924
}
29232925

29242926
Type visitEditorPlaceholderExpr(EditorPlaceholderExpr *E) {

lib/Sema/CodeSynthesis.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1294,7 +1294,9 @@ static void synthesizeLazyGetterBody(AbstractFunctionDecl *fn, void *context) {
12941294
// FIXME: we should really have stronger invariants than this. Leaving it
12951295
// unwrapped may expose both expressions to naive walkers
12961296
if (wasInitializerChecked) {
1297+
auto initType = InitValue->getType();
12971298
InitValue = new (Ctx) LazyInitializerExpr(InitValue);
1299+
InitValue->setType(initType);
12981300
}
12991301

13001302
Pattern *Tmp2PBDPattern = new (Ctx) NamedPattern(Tmp2VD, /*implicit*/true);

0 commit comments

Comments
 (0)