Derive the SIL linkage of a witness table from the minimum of the protocol’s and conforming type’s visibility.

For example, if an internal type conforms to a public protocol, the witness table should get internal linkage.
Previously we only considered the visibility of the protocol.

Fragile witness tables still have to get public symbol linkage. This is now handled in IRGen (like we do it for functions).
This commit is contained in:
Erik Eckstein
2017-01-18 14:06:18 -08:00
parent 7dab73e980
commit cb0ebae078
5 changed files with 33 additions and 31 deletions

View File

@@ -129,14 +129,9 @@ swift::getLinkageForProtocolConformance(const NormalProtocolConformance *C,
&& conformanceModule == typeUnit->getParentModule())
return SILLinkage::Shared;
// If we're building with -sil-serialize-all, give the conformance public
// linkage.
if (conformanceModule->getResilienceStrategy()
== ResilienceStrategy::Fragile)
return (definition ? SILLinkage::Public : SILLinkage::PublicExternal);
// FIXME: This should be using std::min(protocol's access, type's access).
switch (C->getProtocol()->getEffectiveAccess()) {
Accessibility accessibility = std::min(C->getProtocol()->getEffectiveAccess(),
typeDecl->getEffectiveAccess());
switch (accessibility) {
case Accessibility::Private:
case Accessibility::FilePrivate:
return (definition ? SILLinkage::Private : SILLinkage::PrivateExternal);