Skip to content

Commit 5f20823

Browse files
committed
SIL: Enforce new rules on witness visibility in SILVerifier
1 parent 56ad8bd commit 5f20823

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

lib/SIL/SILVerifier.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4044,15 +4044,20 @@ void SILWitnessTable::verify(const SILModule &M) const {
40444044

40454045
auto *protocol = getConformance()->getProtocol();
40464046

4047-
// Currently all witness tables have public conformances, thus witness tables
4048-
// should not reference SILFunctions without public/public_external linkage.
4049-
// FIXME: Once we support private conformances, update this.
40504047
for (const Entry &E : getEntries())
40514048
if (E.getKind() == SILWitnessTable::WitnessKind::Method) {
40524049
SILFunction *F = E.getMethodWitness().Witness;
40534050
if (F) {
4054-
assert(!isLessVisibleThan(F->getLinkage(), getLinkage()) &&
4055-
"Witness tables should not reference less visible functions.");
4051+
// If a SILWitnessTable is going to be serialized, it must only
4052+
// reference public or shared [fragile] functions.
4053+
if (isFragile()) {
4054+
assert((!isLessVisibleThan(F->getLinkage(), getLinkage()) ||
4055+
(F->isFragile() &&
4056+
F->getLinkage() == SILLinkage::Shared)) &&
4057+
"Fragile witness tables should not reference "
4058+
"less visible functions.");
4059+
}
4060+
40564061
assert(F->getLoweredFunctionType()->getRepresentation() ==
40574062
SILFunctionTypeRepresentation::WitnessMethod &&
40584063
"Witnesses must have witness_method representation.");

0 commit comments

Comments
 (0)