[Serialization] Distinguish between protocol/extension for types too. (#7794)

Replace an existing flag for cross-references to member types (that
wasn't getting much use) with one consistent with how we lookup
values. This fixes the case where someone actually has a useful type
as a member of a protocol extension, and that type gets referenced in
another module; Dispatch does exactly this.

Because you can currently only define typealiases in protocol
extensions, not new types, there's always a workaround for someone
hitting this issue: just use the underlying type.

https://bugs.swift.org/browse/SR-4076
This commit is contained in:
Jordan Rose
2017-02-28 10:36:46 -08:00
committed by GitHub
parent 48c10aa00b
commit 3639343c53
6 changed files with 14 additions and 10 deletions

View File

@@ -1803,18 +1803,17 @@ void Serializer::writeCrossReference(const Decl *D) {
return;
}
bool isProtocolExt = D->getDeclContext()->getAsProtocolExtensionContext();
if (auto type = dyn_cast<TypeDecl>(D)) {
abbrCode = DeclTypeAbbrCodes[XRefTypePathPieceLayout::Code];
XRefTypePathPieceLayout::emitRecord(Out, ScratchRecord, abbrCode,
addIdentifierRef(type->getName()),
isa<ProtocolDecl>(
type->getDeclContext()));
isProtocolExt);
return;
}
auto val = cast<ValueDecl>(D);
auto ty = val->getInterfaceType()->getCanonicalType();
bool isProtocolExt = D->getDeclContext()->getAsProtocolExtensionContext();
abbrCode = DeclTypeAbbrCodes[XRefValuePathPieceLayout::Code];
XRefValuePathPieceLayout::emitRecord(Out, ScratchRecord, abbrCode,
addTypeRef(ty),