Sema: Set the interface type of lazy properties during validation.

Otherwise, we end up treating the contextual type as the interface type in situations where the lazy property is seen from other files. Fixes SR-837.
This commit is contained in:
Joe Groff
2016-04-04 13:16:10 -07:00
parent 2d8d7ad8b6
commit 88847f177a
3 changed files with 13 additions and 0 deletions

View File

@@ -1581,10 +1581,12 @@ void TypeChecker::completeLazyVarImplementation(VarDecl *VD) {
NameBuf += ".storage";
auto StorageName = Context.getIdentifier(NameBuf);
auto StorageTy = OptionalType::get(VD->getType());
auto StorageInterfaceTy = OptionalType::get(VD->getInterfaceType());
auto *Storage = new (Context) VarDecl(/*isStatic*/false, /*isLet*/false,
VD->getLoc(), StorageName, StorageTy,
VD->getDeclContext());
Storage->setInterfaceType(StorageInterfaceTy);
Storage->setUserAccessible(false);
addMemberToContextIfNeeded(Storage, VD->getDeclContext(), VD);