Skip to content

Commit 14f9e8a

Browse files
committed
Sema: Simplify 'lazy' property completion
finalizeType() should only be called for types in other source files.
1 parent 5449278 commit 14f9e8a

File tree

1 file changed

+2
-21
lines changed

1 file changed

+2
-21
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7992,8 +7992,6 @@ static void finalizeType(TypeChecker &TC, NominalTypeDecl *nominal) {
79927992
assert(!nominal->hasClangNode());
79937993
assert(isa<SourceFile>(nominal->getModuleScopeContext()));
79947994

7995-
Optional<bool> lazyVarsAlreadyHaveImplementation;
7996-
79977995
if (auto *classDecl = dyn_cast<ClassDecl>(nominal))
79987996
TC.requestSuperclassLayout(classDecl);
79997997

@@ -8008,31 +8006,14 @@ static void finalizeType(TypeChecker &TC, NominalTypeDecl *nominal) {
80088006
TC.validateDecl(VD);
80098007

80108008
// The only thing left to do is synthesize storage for lazy variables.
8011-
// We only have to do that if it's a type from another file, though.
8012-
// In NDEBUG builds, bail out as soon as we can.
8013-
#ifdef NDEBUG
8014-
if (lazyVarsAlreadyHaveImplementation.hasValue() &&
8015-
lazyVarsAlreadyHaveImplementation.getValue())
8016-
continue;
8017-
#endif
80188009
auto *prop = dyn_cast<VarDecl>(D);
80198010
if (!prop)
80208011
continue;
80218012

80228013
if (prop->getAttrs().hasAttribute<LazyAttr>() && !prop->isStatic()
80238014
&& prop->getGetter()) {
8024-
bool hasImplementation = prop->getGetter()->hasBody();
8025-
8026-
if (lazyVarsAlreadyHaveImplementation.hasValue()) {
8027-
assert(lazyVarsAlreadyHaveImplementation.getValue() ==
8028-
hasImplementation &&
8029-
"only some lazy vars already have implementations");
8030-
} else {
8031-
lazyVarsAlreadyHaveImplementation = hasImplementation;
8032-
}
8033-
8034-
if (!hasImplementation)
8035-
TC.completeLazyVarImplementation(prop);
8015+
assert(!prop->getGetter()->hasBody());
8016+
TC.completeLazyVarImplementation(prop);
80368017
}
80378018
}
80388019

0 commit comments

Comments
 (0)