Skip to content

Commit d80cefc

Browse files
committed
Do not type check lazy accessor bodies eagerly.
Start chipping away at cross-file type checker performance issues by avoiding type checking of lazy property accessor bodies when the type in question is defined in a different file and the lazy property is a typed pattern. We still type check these in the file they are defined in when we go to type check the types defined within that file. Resolves rdar://problem/26894118.
1 parent 3c4a93c commit d80cefc

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

lib/Sema/CodeSynthesis.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,6 +1625,7 @@ void TypeChecker::completeLazyVarImplementation(VarDecl *VD) {
16251625

16261626
// Now that we've got the storage squared away, synthesize the getter.
16271627
auto *Get = completeLazyPropertyGetter(VD, Storage, *this);
1628+
validateDecl(Get);
16281629

16291630
// The setter just forwards on to storage without materializing the initial
16301631
// value.
@@ -1643,12 +1644,6 @@ void TypeChecker::completeLazyVarImplementation(VarDecl *VD) {
16431644
Storage->setImplicit();
16441645
Storage->setAccessibility(Accessibility::Private);
16451646
Storage->setSetterAccessibility(Accessibility::Private);
1646-
1647-
typeCheckDecl(Get, true);
1648-
typeCheckDecl(Get, false);
1649-
1650-
typeCheckDecl(Set, true);
1651-
typeCheckDecl(Set, false);
16521647
}
16531648

16541649

test/Sema/Inputs/forbid_typecheck_2.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ class NOTYPECHECK_cls {}
88

99
class ClsSec {
1010
let member : Int = NOTYPECHECK_member
11+
lazy var lazymember: Int = NOTYPECHECK_lazymember
1112
}

0 commit comments

Comments
 (0)