[Serialization] Distinguish between static and non-static vars. (#7176)

Every other declaration kind gets this for free in its interface type,
but properties don't. Just add a bit, it's simple enough.

rdar://problem/30289803
This commit is contained in:
Jordan Rose
2017-02-01 09:55:41 -08:00
committed by GitHub
parent 3d3fdecbb4
commit 6f63c77353
5 changed files with 38 additions and 17 deletions

View File

@@ -1270,7 +1270,7 @@ getActualCtorInitializerKind(uint8_t raw) {
/// from Clang can also appear in any module.
static void filterValues(Type expectedTy, ModuleDecl *expectedModule,
CanGenericSignature expectedGenericSig, bool isType,
bool inProtocolExt,
bool inProtocolExt, bool isStatic,
Optional<swift::CtorInitializerKind> ctorInit,
SmallVectorImpl<ValueDecl *> &values) {
CanType canTy;
@@ -1285,6 +1285,8 @@ static void filterValues(Type expectedTy, ModuleDecl *expectedModule,
return true;
if (canTy && value->getInterfaceType()->getCanonicalType() != canTy)
return true;
if (value->isStatic() != isStatic)
return true;
// FIXME: Should be able to move a value from an extension in a derived
// module to the original definition in a base module.
if (expectedModule && !value->hasClangNode() &&
@@ -1356,10 +1358,12 @@ Decl *ModuleFile::resolveCrossReference(ModuleDecl *M, uint32_t pathLen) {
bool isType = (recordID == XREF_TYPE_PATH_PIECE);
bool onlyInNominal = false;
bool inProtocolExt = false;
bool isStatic = false;
if (isType)
XRefTypePathPieceLayout::readRecord(scratch, IID, onlyInNominal);
else
XRefValuePathPieceLayout::readRecord(scratch, TID, IID, inProtocolExt);
XRefValuePathPieceLayout::readRecord(scratch, TID, IID, inProtocolExt,
isStatic);
Identifier name = getIdentifier(IID);
pathTrace.addValue(name);
@@ -1374,8 +1378,8 @@ Decl *ModuleFile::resolveCrossReference(ModuleDecl *M, uint32_t pathLen) {
M->lookupQualified(ModuleType::get(M), name,
NL_QualifiedDefault | NL_KnownNoDependency,
/*typeResolver=*/nullptr, values);
filterValues(filterTy, nullptr, nullptr, isType, inProtocolExt, None,
values);
filterValues(filterTy, nullptr, nullptr, isType, inProtocolExt, isStatic,
None, values);
// HACK HACK HACK: Omit-needless-words hack to try to cope with
// the "NS" prefix being added/removed. No "real" compiler mode
@@ -1531,6 +1535,7 @@ Decl *ModuleFile::resolveCrossReference(ModuleDecl *M, uint32_t pathLen) {
bool isType = false;
bool onlyInNominal = false;
bool inProtocolExt = false;
bool isStatic = false;
switch (recordID) {
case XREF_TYPE_PATH_PIECE: {
IdentifierID IID;
@@ -1542,7 +1547,8 @@ Decl *ModuleFile::resolveCrossReference(ModuleDecl *M, uint32_t pathLen) {
case XREF_VALUE_PATH_PIECE: {
IdentifierID IID;
XRefValuePathPieceLayout::readRecord(scratch, TID, IID, inProtocolExt);
XRefValuePathPieceLayout::readRecord(scratch, TID, IID, inProtocolExt,
isStatic);
memberName = getIdentifier(IID);
break;
}
@@ -1581,8 +1587,8 @@ Decl *ModuleFile::resolveCrossReference(ModuleDecl *M, uint32_t pathLen) {
auto members = nominal->lookupDirect(memberName, onlyInNominal);
values.append(members.begin(), members.end());
filterValues(filterTy, M, genericSig, isType, inProtocolExt, ctorInit,
values);
filterValues(filterTy, M, genericSig, isType, inProtocolExt, isStatic,
ctorInit, values);
break;
}