Skip to content

Commit 448ef26

Browse files
committed
Revert "[Package CMO] Remove workaround for skipped types in serializability pass"
This reverts commit 41bb2e0.
1 parent 85c2728 commit 448ef26

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

lib/SILOptimizer/IPO/CrossModuleOptimization.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,21 @@ void CrossModuleOptimization::makeDeclUsableFromInline(ValueDecl *decl) {
938938
if (decl->getEffectiveAccess() >= AccessLevel::Package)
939939
return;
940940

941+
// FIXME: rdar://130456707
942+
// Currently not all types are visited in canSerialize* calls, sometimes
943+
// resulting in an internal type getting @usableFromInline, which is
944+
// incorrect.
945+
// For example, for `let q = P() as? Q`, where Q is an internal class
946+
// inherting a public class P, Q is not visited in the canSerialize*
947+
// checks, thus resulting in `@usableFromInline class Q`; this is not
948+
// the intended behavior in the conservative mode as it modifies AST.
949+
//
950+
// To properly fix, instruction visitor needs to be refactored to do
951+
// both the "canSerialize" check (that visits all types) and serialize
952+
// or update visibility (modify AST in non-conservative modes).
953+
if (isPackageCMOEnabled(M.getSwiftModule()))
954+
return;
955+
941956
// We must not modify decls which are defined in other modules.
942957
if (M.getSwiftModule() != decl->getDeclContext()->getParentModule())
943958
return;

0 commit comments

Comments
 (0)