SILGen: Fix key paths that reference internal private(set) decls from other files.

The setter needs to be given hidden linkage so that other files can still form key paths to it.
This commit is contained in:
Joe Groff
2018-07-09 20:19:51 -07:00
parent b607e549f1
commit ae4d40ac85
8 changed files with 81 additions and 5 deletions

View File

@@ -314,8 +314,19 @@ SILLinkage SILDeclRef::getLinkage(ForDefinition_t forDefinition) const {
neverPublic = true;
}
}
auto effectiveAccess = d->getEffectiveAccess();
// Private setter implementations for an internal storage declaration should
// be internal as well, so that a dynamically-writable
// keypath can be formed from other files.
if (auto accessor = dyn_cast<AccessorDecl>(d)) {
if (accessor->isSetter()
&& accessor->getStorage()->getEffectiveAccess() == AccessLevel::Internal)
effectiveAccess = AccessLevel::Internal;
}
switch (d->getEffectiveAccess()) {
switch (effectiveAccess) {
case AccessLevel::Private:
case AccessLevel::FilePrivate:
return maybeAddExternal(SILLinkage::Private);