@@ -2774,44 +2774,44 @@ bool VarDecl::isInitExposedToClients() const {
27742774 if (getAttrs ().hasAttribute <LazyAttr>())
27752775 return false ;
27762776
2777- return hasInitialValue () && isLayoutExposedToClients ();
2777+ return hasInitialValue () &&
2778+ isLayoutExposedToClients () == ExportedLevel::Exported;
27782779}
27792780
2780- bool VarDecl::isLayoutExposedToClients (bool applyImplicit ) const {
2781+ ExportedLevel VarDecl::isLayoutExposedToClients () const {
27812782 auto parent = dyn_cast<NominalTypeDecl>(getDeclContext ());
2782- if (!parent) return false ;
2783- if (isStatic ()) return false ;
2783+ if (!parent) return ExportedLevel::None ;
2784+ if (isStatic ()) return ExportedLevel::None ;
27842785
2785- auto M = getDeclContext ()->getParentModule ();
2786+ // Does it contribute to the layout?
2787+ if (!hasStorage () &&
2788+ !getAttrs ().hasAttribute <LazyAttr>() &&
2789+ !hasAttachedPropertyWrapper ()) {
2790+ return ExportedLevel::None;
2791+ }
2792+
2793+ // Is it a member of a frozen type?
27862794 auto nominalAccess =
27872795 parent->getFormalAccessScope (/* useDC=*/ nullptr ,
27882796 /* treatUsableFromInlineAsPublic=*/ true );
2797+ if (nominalAccess.isPublic () &&
2798+ (parent->getAttrs ().hasAttribute <FrozenAttr>() ||
2799+ parent->getAttrs ().hasAttribute <FixedLayoutAttr>()))
2800+ return ExportedLevel::Exported;
27892801
2790- // Resilient modules and classes hide layouts by default.
2791- bool layoutIsHiddenByDefault = !applyImplicit ||
2792- !getASTContext ().LangOpts .hasFeature (Feature::CheckImplementationOnly) ||
2793- M->getResilienceStrategy () == ResilienceStrategy::Resilient;
2794- if (layoutIsHiddenByDefault) {
2795- if (!nominalAccess.isPublic ())
2796- return false ;
2802+ // Is it a member of an `@_implementationOnly` type?
2803+ if (parent->getAttrs ().hasAttribute <ImplementationOnlyAttr>())
2804+ return ExportedLevel::None;
27972805
2798- if (!parent->getAttrs ().hasAttribute <FrozenAttr>() &&
2799- !parent->getAttrs ().hasAttribute <FixedLayoutAttr>())
2800- return false ;
2806+ auto M = getDeclContext ()->getParentModule ();
2807+ if (getASTContext ().LangOpts .hasFeature (Feature::CheckImplementationOnly) &&
2808+ M->getResilienceStrategy () != ResilienceStrategy::Resilient) {
2809+ // Non-resilient module expose layouts by default.
2810+ return ExportedLevel::ImplicitlyExported;
28012811 } else {
2802- // Non-resilient module: layouts are exposed by default unless marked
2803- // otherwise.
2804- if (parent->getAttrs ().hasAttribute <ImplementationOnlyAttr>())
2805- return false ;
2812+ // Resilient modules hide layouts by default.
2813+ return ExportedLevel::None;
28062814 }
2807-
2808- if (!hasStorage () &&
2809- !getAttrs ().hasAttribute <LazyAttr>() &&
2810- !hasAttachedPropertyWrapper ()) {
2811- return false ;
2812- }
2813-
2814- return true ;
28152815}
28162816
28172817// / Check whether the given type representation will be
0 commit comments