@@ -2982,11 +2982,6 @@ class DeclChecker : public DeclVisitor<DeclChecker> {
2982
2982
2983
2983
TC.checkDeclCircularity (CD);
2984
2984
TC.ConformanceContexts .push_back (CD);
2985
-
2986
- for (auto Member : CD->getMembers ()) {
2987
- if (auto VD = dyn_cast<ValueDecl>(Member))
2988
- TC.requestMemberLayout (VD);
2989
- }
2990
2985
}
2991
2986
2992
2987
void visitProtocolDecl (ProtocolDecl *PD) {
@@ -4599,13 +4594,6 @@ void TypeChecker::requestMemberLayout(ValueDecl *member) {
4599
4594
if (auto *protocolDecl = dyn_cast<ProtocolDecl>(dc))
4600
4595
requestNominalLayout (protocolDecl);
4601
4596
4602
- // Compute overrides.
4603
- (void )member->getOverriddenDecls ();
4604
-
4605
- // Check whether the member is @objc or dynamic.
4606
- (void )member->isObjC ();
4607
- (void )member->isDynamic ();
4608
-
4609
4597
// If this represents (abstract) storage, form the appropriate accessors.
4610
4598
if (auto storage = dyn_cast<AbstractStorageDecl>(member)) {
4611
4599
validateAbstractStorageDecl (*this , storage);
@@ -4641,10 +4629,21 @@ void TypeChecker::requestSuperclassLayout(ClassDecl *classDecl) {
4641
4629
}
4642
4630
}
4643
4631
4632
+ // / "Finalize" the type so that SILGen can make copies of it, call
4633
+ // / methods on it, etc. This requires forcing enough computation so
4634
+ // / that (for example) a class can layout its vtable or a struct can
4635
+ // / be laid out in memory.
4644
4636
static void finalizeType (TypeChecker &TC, NominalTypeDecl *nominal) {
4645
4637
assert (!nominal->hasClangNode ());
4646
4638
assert (isa<SourceFile>(nominal->getModuleScopeContext ()));
4647
4639
4640
+ if (auto *CD = dyn_cast<ClassDecl>(nominal)) {
4641
+ // We need to add implicit initializers and dtors because it
4642
+ // affects vtable layout.
4643
+ TC.addImplicitConstructors (CD);
4644
+ CD->addImplicitDestructor ();
4645
+ }
4646
+
4648
4647
for (auto *D : nominal->getMembers ()) {
4649
4648
auto VD = dyn_cast<ValueDecl>(D);
4650
4649
if (!VD)
@@ -4655,7 +4654,12 @@ static void finalizeType(TypeChecker &TC, NominalTypeDecl *nominal) {
4655
4654
4656
4655
TC.validateDecl (VD);
4657
4656
4658
- TC.requestMemberLayout (VD);
4657
+ // Compute overrides.
4658
+ (void )VD->getOverriddenDecls ();
4659
+
4660
+ // Check whether the member is @objc or dynamic.
4661
+ (void )VD->isObjC ();
4662
+ (void )VD->isDynamic ();
4659
4663
4660
4664
// The only thing left to do is synthesize storage for lazy variables.
4661
4665
auto *prop = dyn_cast<VarDecl>(D);
@@ -4670,11 +4674,6 @@ static void finalizeType(TypeChecker &TC, NominalTypeDecl *nominal) {
4670
4674
}
4671
4675
4672
4676
if (auto *CD = dyn_cast<ClassDecl>(nominal)) {
4673
- // We need to add implicit initializers and dtors because it
4674
- // affects vtable layout.
4675
- TC.addImplicitConstructors (CD);
4676
- CD->addImplicitDestructor ();
4677
-
4678
4677
// We need the superclass vtable layout as well.
4679
4678
TC.requestSuperclassLayout (CD);
4680
4679
@@ -5535,9 +5534,6 @@ void TypeChecker::addImplicitConstructors(NominalTypeDecl *decl) {
5535
5534
*this , classDecl, superclassCtor, kind)) {
5536
5535
Context.addSynthesizedDecl (ctor);
5537
5536
classDecl->addMember (ctor);
5538
-
5539
- if (classDecl->hasValidatedLayout ())
5540
- requestMemberLayout (ctor);
5541
5537
}
5542
5538
}
5543
5539
0 commit comments