Skip to content

Commit 38b19c0

Browse files
committed
Make VarDecl::isLayoutExposedToClients check property wrappers more lazily
The check for "has property wrappers" as part of determining whether the layout of a variable is exposed to clients can trigger reference cycles. Push this check later, which eliminates these cycles for types that aren't frozen/fixed-layout. This is a hack, not a real fix, but it eliminates the cyclic references observed in rdar://112079160.
1 parent abe8b37 commit 38b19c0

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/AST/Decl.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2079,19 +2079,23 @@ bool VarDecl::isLayoutExposedToClients() const {
20792079
if (!parent) return false;
20802080
if (isStatic()) return false;
20812081

2082-
if (!hasStorage() &&
2083-
!getAttrs().hasAttribute<LazyAttr>() &&
2084-
!hasAttachedPropertyWrapper()) {
2085-
return false;
2086-
}
20872082

20882083
auto nominalAccess =
20892084
parent->getFormalAccessScope(/*useDC=*/nullptr,
20902085
/*treatUsableFromInlineAsPublic=*/true);
20912086
if (!nominalAccess.isPublic()) return false;
20922087

2093-
return (parent->getAttrs().hasAttribute<FrozenAttr>() ||
2094-
parent->getAttrs().hasAttribute<FixedLayoutAttr>());
2088+
if (!parent->getAttrs().hasAttribute<FrozenAttr>() &&
2089+
!parent->getAttrs().hasAttribute<FixedLayoutAttr>())
2090+
return false;
2091+
2092+
if (!hasStorage() &&
2093+
!getAttrs().hasAttribute<LazyAttr>() &&
2094+
!hasAttachedPropertyWrapper()) {
2095+
return false;
2096+
}
2097+
2098+
return true;
20952099
}
20962100

20972101
/// Check whether the given type representation will be

0 commit comments

Comments
 (0)