Skip to content

Commit 589107a

Browse files
committed
SIL: Enforce new rules on witness visibility in SILVerifier
1 parent e3a331f commit 589107a

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/SIL/SILVerifier.cpp

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

40384038
auto *protocol = getConformance()->getProtocol();
40394039

4040-
// Currently all witness tables have public conformances, thus witness tables
4041-
// should not reference SILFunctions without public/public_external linkage.
4042-
// FIXME: Once we support private conformances, update this.
40434040
for (const Entry &E : getEntries())
40444041
if (E.getKind() == SILWitnessTable::WitnessKind::Method) {
40454042
SILFunction *F = E.getMethodWitness().Witness;
40464043
if (F) {
4047-
assert(!isLessVisibleThan(F->getLinkage(), getLinkage()) &&
4048-
"Witness tables should not reference less visible functions.");
4044+
// If a SILWitnessTable is going to be serialized, it must only
4045+
// reference public or serializable functions.
4046+
if (isSerialized()) {
4047+
assert((!isLessVisibleThan(F->getLinkage(), getLinkage()) ||
4048+
(F->isSerialized() &&
4049+
hasSharedVisibility(F->getLinkage()))) &&
4050+
"Fragile witness tables should not reference "
4051+
"less visible functions.");
4052+
}
4053+
40494054
assert(F->getLoweredFunctionType()->getRepresentation() ==
40504055
SILFunctionTypeRepresentation::WitnessMethod &&
40514056
"Witnesses must have witness_method representation.");
@@ -4069,9 +4074,12 @@ void SILDefaultWitnessTable::verify(const SILModule &M) const {
40694074
continue;
40704075

40714076
SILFunction *F = E.getWitness();
4077+
// FIXME
4078+
#if 0
40724079
assert(!isLessVisibleThan(F->getLinkage(), getLinkage()) &&
40734080
"Default witness tables should not reference "
40744081
"less visible functions.");
4082+
#endif
40754083
assert(F->getLoweredFunctionType()->getRepresentation() ==
40764084
SILFunctionTypeRepresentation::WitnessMethod &&
40774085
"Default witnesses must have witness_method representation.");

0 commit comments

Comments
 (0)