[Serialization] Mark decls that can never be cross-referenced (#17223)

This allows us to filter them out in cases that would otherwise be
ambiguous. The particular prompting situation looks a lot like the
test case: a protocol, plus a forward-declared class with the same
name. (Normally we ignore forward-declared classes, but SourceKit's
module interface generation feature makes dummy ClassDecls for them
instead.)

https://bugs.swift.org/browse/SR-4851
This commit is contained in:
Jordan Rose
2018-06-18 10:50:35 -07:00
committed by GitHub
parent c16d9ce746
commit 05d0a2dfef
9 changed files with 34 additions and 0 deletions

View File

@@ -603,6 +603,10 @@ DeclID Serializer::addDeclRef(const Decl *D, bool forceSerialization,
isa<PrecedenceGroupDecl>(D)) &&
"cannot cross-reference this decl");
assert((!isDeclXRef(D) ||
!D->getAttrs().hasAttribute<ForbidSerializingReferenceAttr>()) &&
"cannot cross-reference this decl");
assert((allowTypeAliasXRef || !isa<TypeAliasDecl>(D) ||
D->getModuleContext() == M) &&
"cannot cross-reference typealiases directly (use the NameAliasType)");