Skip to content

Commit 128f4a8

Browse files
committed
SIL: Verify that we don't emit function_refs to externally-defined methods in resilient classes
1 parent c750f56 commit 128f4a8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/SIL/SILFunction.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,16 @@ bool SILFunction::hasValidLinkageForFragileRef() const {
477477
if (hasValidLinkageForFragileInline())
478478
return true;
479479

480-
// If the containing module has been serialized
481-
if (getModule().isSerialized()) {
480+
// If the containing module has been serialized already, we no longer
481+
// enforce any invariants.
482+
if (getModule().isSerialized())
482483
return true;
483-
}
484+
485+
// If the function has a subclass scope that limits its visibility outside
486+
// the module despite its linkage, we cannot reference it.
487+
if (getClassSubclassScope() == SubclassScope::Resilient &&
488+
isAvailableExternally())
489+
return false;
484490

485491
// Otherwise, only public functions can be referenced.
486492
return hasPublicVisibility(getLinkage());

0 commit comments

Comments
 (0)