[CodeSynthesis] Make sure that LazyInitializerExpr has a type

Currently when `LazyInitializerExpr` is added to the AST it's not
given an explicit type. Because of that constraint solver silently
fails in contraint generator without diagnostic. But since
sub-expression associated with `LazyInitializerExpr` is already
type-checked it makes sense to set its type explicitly.
This commit is contained in:
Pavel Yaskevich
2018-12-19 12:10:07 -08:00
parent 60e54db9a5
commit 20b7c2a4ba
3 changed files with 8 additions and 3 deletions

View File

@@ -1294,7 +1294,9 @@ static void synthesizeLazyGetterBody(AbstractFunctionDecl *fn, void *context) {
// FIXME: we should really have stronger invariants than this. Leaving it
// unwrapped may expose both expressions to naive walkers
if (wasInitializerChecked) {
auto initType = InitValue->getType();
InitValue = new (Ctx) LazyInitializerExpr(InitValue);
InitValue->setType(initType);
}
Pattern *Tmp2PBDPattern = new (Ctx) NamedPattern(Tmp2VD, /*implicit*/true);