mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Simplify parsing and representation of extension declarations.
Now that we don't have generic parameter lists at arbitrary positions within the extended type of an extension declaration, simplify the representation of the extended type down to a TypeLoc along with a (compiler-synthesized) generic parameter list. On the parsing side, just parse a type for the extended type, rather than having a special grammar. We still reject anything that is not a nominal type (of course), but it's simpler just to call it a type. As a drive-by, fix the crasher when extending a type with module qualification, rdar://problem/20900870. Swift SVN r28469
This commit is contained in:
@@ -1943,19 +1943,16 @@ void Serializer::writeDecl(const Decl *D) {
|
||||
// parameters.
|
||||
(void)addDeclRef(baseTy->getAnyNominal());
|
||||
|
||||
SmallVector<DeclID, 8> protocolsAndRefTypes;
|
||||
SmallVector<DeclID, 8> protocols;
|
||||
for (auto proto : extension->getLocalProtocols())
|
||||
protocolsAndRefTypes.push_back(addDeclRef(proto));
|
||||
for (const auto &ref : extension->getRefComponents())
|
||||
protocolsAndRefTypes.push_back(addTypeRef(ref.IdentType.getType()));
|
||||
protocols.push_back(addDeclRef(proto));
|
||||
|
||||
unsigned abbrCode = DeclTypeAbbrCodes[ExtensionLayout::Code];
|
||||
ExtensionLayout::emitRecord(Out, ScratchRecord, abbrCode,
|
||||
addTypeRef(baseTy),
|
||||
contextID,
|
||||
extension->isImplicit(),
|
||||
extension->getRefComponents().size(),
|
||||
protocolsAndRefTypes);
|
||||
protocols);
|
||||
|
||||
bool isClassExtension = false;
|
||||
if (auto baseNominal = baseTy->getAnyNominal()) {
|
||||
@@ -1963,9 +1960,7 @@ void Serializer::writeDecl(const Decl *D) {
|
||||
isa<ProtocolDecl>(baseNominal);
|
||||
}
|
||||
|
||||
for (const auto &ref : extension->getRefComponents())
|
||||
writeGenericParams(ref.GenericParams, DeclTypeAbbrCodes);
|
||||
|
||||
writeGenericParams(extension->getGenericParams(), DeclTypeAbbrCodes);
|
||||
writeRequirements(extension->getGenericRequirements());
|
||||
writeMembers(extension->getMembers(), isClassExtension);
|
||||
writeConformances(extension->getLocalConformances(),
|
||||
|
||||
Reference in New Issue
Block a user