diff --git a/lib/Sema/CodeSynthesis.cpp b/lib/Sema/CodeSynthesis.cpp index f9f5c0e8706..9088f041dae 100644 --- a/lib/Sema/CodeSynthesis.cpp +++ b/lib/Sema/CodeSynthesis.cpp @@ -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); diff --git a/test/decl/var/Inputs/lazy_properties_multi_file_2.swift b/test/decl/var/Inputs/lazy_properties_multi_file_2.swift new file mode 100644 index 00000000000..5d0aae90f1e --- /dev/null +++ b/test/decl/var/Inputs/lazy_properties_multi_file_2.swift @@ -0,0 +1,4 @@ +struct MyGenericStruct { + lazy var prop2 = [AnotherGenericStruct]() +} +struct AnotherGenericStruct { } diff --git a/test/decl/var/lazy_properties_multi_file.swift b/test/decl/var/lazy_properties_multi_file.swift new file mode 100644 index 00000000000..95f9b8131ea --- /dev/null +++ b/test/decl/var/lazy_properties_multi_file.swift @@ -0,0 +1,7 @@ +// RUN: rm -rf %t +// RUN: mkdir -p %t +// RUN: %target-swift-frontend %s -verify -O -primary-file %s %S/Inputs/lazy_properties_multi_file_2.swift -c -o %t/lazy_properties_multi_file.o + +class MyClass { + var myProperty = MyGenericStruct() +}