@@ -93,7 +93,7 @@ template <class Impl> class ClassMetadataVisitor
9393 asImpl ().addIVarDestroyer ();
9494
9595 // Class members.
96- addClassMembers (Target);
96+ addClassMembers (Target, Target );
9797 }
9898
9999 // / Notes the beginning of the field offset vector for a particular ancestor
@@ -110,9 +110,11 @@ template <class Impl> class ClassMetadataVisitor
110110
111111private:
112112 // / Add fields associated with the given class and its bases.
113- void addClassMembers (ClassDecl *theClass) {
113+ void addClassMembers (ClassDecl *theClass,
114+ ClassDecl *rootClass) {
114115 // Visit the superclass first.
115116 if (auto *superclassDecl = theClass->getSuperclassDecl ()) {
117+
116118 if (superclassDecl->hasClangNode ()) {
117119 // Nothing to do; Objective-C classes do not add new members to
118120 // Swift class metadata.
@@ -123,10 +125,9 @@ template <class Impl> class ClassMetadataVisitor
123125 // not publically accessible (e.g private or internal). This would
124126 // normally not happen except if we compile theClass's module with
125127 // enable-testing.
126- } else if (IGM.hasResilientMetadata (superclassDecl, ResilienceExpansion::Maximal) &&
127- (theClass->getModuleContext () == IGM.getSwiftModule () ||
128- theClass->getFormalAccessScope (/* useDC=*/ nullptr ,
129- /* treatUsableFromInlineAsPublic=*/ true ).isPublic ())) {
128+ } else if (IGM.hasResilientMetadata (superclassDecl,
129+ ResilienceExpansion::Maximal,
130+ rootClass)) {
130131 // Runtime metadata instantiation will initialize our field offset
131132 // vector and vtable entries.
132133 //
@@ -137,7 +138,8 @@ template <class Impl> class ClassMetadataVisitor
137138 // NB: We don't apply superclass substitutions to members because we want
138139 // consistent metadata layout between generic superclasses and concrete
139140 // subclasses.
140- addClassMembers (superclassDecl);
141+ addClassMembers (superclassDecl,
142+ rootClass);
141143 }
142144 }
143145
@@ -151,7 +153,8 @@ template <class Impl> class ClassMetadataVisitor
151153
152154 // If the class has resilient storage, we cannot make any assumptions about
153155 // its storage layout, so skip the rest of this method.
154- if (IGM.isResilient (theClass, ResilienceExpansion::Maximal))
156+ if (IGM.isResilient (theClass, ResilienceExpansion::Maximal,
157+ rootClass))
155158 return ;
156159
157160 // A class only really *needs* a field-offset vector in the
@@ -175,7 +178,8 @@ template <class Impl> class ClassMetadataVisitor
175178
176179 // If the class has resilient metadata, we cannot make any assumptions
177180 // about its metadata layout, so skip the rest of this method.
178- if (IGM.hasResilientMetadata (theClass, ResilienceExpansion::Maximal))
181+ if (IGM.hasResilientMetadata (theClass, ResilienceExpansion::Maximal,
182+ rootClass))
179183 return ;
180184
181185 // Add vtable entries.
0 commit comments