Skip to content

Commit 9b7f3f7

Browse files
committed
Sema: Don't validate class layout when validating an extension
We only need to validate all the members of a class when we type check an extension, which means we will generate code for it. Merely validating an extension, as happens during name lookup, does not need to validate all members of a class.
1 parent e659bef commit 9b7f3f7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/Sema/TypeCheckDecl.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6906,6 +6906,9 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
69066906
if (auto extendedTy = ED->getExtendedType()) {
69076907
if (auto nominal = extendedTy->getAnyNominal()) {
69086908
TC.validateDecl(nominal);
6909+
if (auto *classDecl = dyn_cast<ClassDecl>(nominal))
6910+
TC.requestClassLayout(classDecl);
6911+
69096912
// Check the raw values of an enum, since we might synthesize
69106913
// RawRepresentable while checking conformances on this extension.
69116914
if (auto enumDecl = dyn_cast<EnumDecl>(nominal)) {
@@ -8180,8 +8183,6 @@ void TypeChecker::validateExtension(ExtensionDecl *ext) {
81808183
// Validate the nominal type declaration being extended.
81818184
auto nominal = extendedType->getAnyNominal();
81828185
validateDecl(nominal);
8183-
if (auto *classDecl = dyn_cast<ClassDecl>(nominal))
8184-
requestClassLayout(classDecl);
81858186

81868187
if (nominal->getGenericParamsOfContext()) {
81878188
auto genericParams = ext->getGenericParams();

0 commit comments

Comments
 (0)