From 67e172346157fe69dceb5806ae7bbdf9517c4361 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Aug 2016 05:10:24 -0700 Subject: [PATCH 1/3] Serialization: Remove AllArchetypes serialization altogether --- include/swift/Serialization/ModuleFormat.h | 5 +- lib/Serialization/Deserialization.cpp | 56 +--------------------- lib/Serialization/Serialization.cpp | 7 +-- 3 files changed, 4 insertions(+), 64 deletions(-) diff --git a/include/swift/Serialization/ModuleFormat.h b/include/swift/Serialization/ModuleFormat.h index 2585dde4ef5a6..3cdbc9c3d64e5 100644 --- a/include/swift/Serialization/ModuleFormat.h +++ b/include/swift/Serialization/ModuleFormat.h @@ -53,7 +53,7 @@ const uint16_t VERSION_MAJOR = 0; /// in source control, you should also update the comment to briefly /// describe what change you made. The content of this comment isn't important; /// it just ensures a conflict if two people change the module format. -const uint16_t VERSION_MINOR = 261; // Last change: remove AllArchetypes indexing +const uint16_t VERSION_MINOR = 262; // Last change: remove AllArchetypes using DeclID = PointerEmbeddedInt; using DeclIDField = BCFixed<31>; @@ -1082,8 +1082,7 @@ namespace decls_block { >; using GenericParamListLayout = BCRecordLayout< - GENERIC_PARAM_LIST, - BCArray // Archetypes + GENERIC_PARAM_LIST // The actual parameters and requirements trail the record. >; diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index f704e4c790edf..3f6cc81b1cd57 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -666,58 +666,12 @@ GenericParamList *ModuleFile::maybeReadGenericParams(DeclContext *DC, if (next.Kind != llvm::BitstreamEntry::Record) return nullptr; - // Read the raw archetype IDs into a different scratch buffer - // because we need to keep this alive for longer. - SmallVector rawArchetypeIDsBuffer; - unsigned kind = Cursor.readRecord(next.ID, rawArchetypeIDsBuffer, &blobData); + unsigned kind = Cursor.readRecord(next.ID, scratch, &blobData); if (kind != GENERIC_PARAM_LIST) return nullptr; - // Read in the raw-archetypes buffer, but don't try to consume it yet. - ArrayRef rawArchetypeIDs; - GenericParamListLayout::readRecord(rawArchetypeIDsBuffer, rawArchetypeIDs); - SmallVector params; SmallVector requirements; - SmallVector archetypes; - - // The GenericTypeParamDecls might be from a different module file. - // If so, we need to map the archetype IDs from the serialized - // all-archetypes list in this module file over to the corresponding - // archetypes from the original generic parameter decls, or else - // we'll end up constructing fresh archetypes that don't match the - // ones from the generic parameters. - - // We have to do this mapping before we might call getType on one of - // those archetypes, but after we've read all the generic parameters. - // Therefore we do it lazily. - bool haveMappedArchetypes = false; - auto mapArchetypes = [&] { - if (haveMappedArchetypes) return; - - GenericParamList::deriveAllArchetypes(params, archetypes); - assert(rawArchetypeIDs.size() == archetypes.size()); - for (unsigned index : indices(rawArchetypeIDs)) { - TypeID TID = rawArchetypeIDs[index]; - auto &typeOrOffset = Types[TID-1]; - if (typeOrOffset.isComplete()) { - // FIXME: this assertion is absolutely correct, but it's - // currently fouled up by the presence of archetypes in - // substitutions. Those *should* be irrelevant for all the - // cases where this is wrong, but... - - //assert(typeOrOffset.get().getPointer() == archetypes[index] && - // "already deserialized this archetype to a different type!"); - - // TODO: remove unsafeOverwrite when this hack goes away - typeOrOffset.unsafeOverwrite(archetypes[index]); - } else { - typeOrOffset = archetypes[index]; - } - } - - haveMappedArchetypes = true; - }; while (true) { lastRecordOffset.reset(); @@ -732,8 +686,6 @@ GenericParamList *ModuleFile::maybeReadGenericParams(DeclContext *DC, &blobData); switch (recordID) { case GENERIC_PARAM: { - assert(!haveMappedArchetypes && - "generic parameters interleaved with requirements?"); DeclID paramDeclID; GenericParamLayout::readRecord(scratch, paramDeclID); auto genericParam = cast(getDecl(paramDeclID, DC)); @@ -760,8 +712,6 @@ GenericParamList *ModuleFile::maybeReadGenericParams(DeclContext *DC, GenericRequirementLayout::readRecord(scratch, rawKind, rawTypeIDs[0], rawTypeIDs[1]); - mapArchetypes(); - switch (rawKind) { case GenericRequirementKind::Conformance: { auto subject = TypeLoc::withoutLoc(getType(rawTypeIDs[0])); @@ -817,13 +767,9 @@ GenericParamList *ModuleFile::maybeReadGenericParams(DeclContext *DC, break; } - // Make sure we map the archetypes if we haven't yet. - mapArchetypes(); - auto paramList = GenericParamList::create(getContext(), SourceLoc(), params, SourceLoc(), requirements, SourceLoc()); - paramList->setAllArchetypes(getContext().AllocateCopy(archetypes)); paramList->setOuterParameters(outerParams ? outerParams : DC->getGenericParamsOfContext()); diff --git a/lib/Serialization/Serialization.cpp b/lib/Serialization/Serialization.cpp index f67b222ab263c..5f60e85447b0b 100644 --- a/lib/Serialization/Serialization.cpp +++ b/lib/Serialization/Serialization.cpp @@ -956,13 +956,8 @@ bool Serializer::writeGenericParams(const GenericParamList *genericParams, if (!genericParams) return true; - SmallVector archetypeIDs; - for (auto archetype : genericParams->getAllArchetypes()) - archetypeIDs.push_back(addTypeRef(archetype)); - unsigned abbrCode = abbrCodes[GenericParamListLayout::Code]; - GenericParamListLayout::emitRecord(Out, ScratchRecord, abbrCode, - archetypeIDs); + GenericParamListLayout::emitRecord(Out, ScratchRecord, abbrCode); abbrCode = abbrCodes[GenericParamLayout::Code]; for (auto next : genericParams->getParams()) { From 85651cb63cfc79f3f74e63f2c597fde10ab3a86c Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Aug 2016 02:56:58 -0700 Subject: [PATCH 2/3] AST: Remove AllArchetypes checks from ASTVerifier The AllArchetypes list is going away; there's nothing to check. --- lib/AST/ASTVerifier.cpp | 195 ---------------------------------------- 1 file changed, 195 deletions(-) diff --git a/lib/AST/ASTVerifier.cpp b/lib/AST/ASTVerifier.cpp index f83926c885235..e0acd64479729 100644 --- a/lib/AST/ASTVerifier.cpp +++ b/lib/AST/ASTVerifier.cpp @@ -2084,195 +2084,6 @@ struct ASTNodeBase {}; verifyParsedBase(DD); } - bool checkAllArchetypes(const GenericParamList *generics) { - ArrayRef storedArchetypes = generics->getAllArchetypes(); - - SmallVector derivedBuffer; - ArrayRef derivedArchetypes = - GenericParamList::deriveAllArchetypes(generics->getParams(), - derivedBuffer); - - return (storedArchetypes == derivedArchetypes); - } - - /// Check that the generic requirements line up with the archetypes. - void checkGenericRequirements(Decl *decl, - DeclContext *dc, - GenericFunctionType *genericTy) { - - PrettyStackTraceDecl debugStack("verifying generic requirements", decl); - - // We need to have generic parameters here. - auto genericParams = dc->getGenericParamsOfContext(); - if (!genericParams) { - Out << "Missing generic parameters\n"; - decl->dump(Out); - abort(); - } - - // Verify that the list of all archetypes matches what we would - // derive from the generic params. - if (!checkAllArchetypes(genericParams)) { - Out << "Archetypes list in generic parameter list doesn't " - "match what would have been derived\n"; - decl->dump(Out); - abort(); - } - - // Step through the list of requirements in the generic type. - auto requirements = genericTy->getRequirements(); - - // Skip over same-type requirements. - auto skipUnrepresentedRequirements = [&]() { - for (; !requirements.empty(); requirements = requirements.slice(1)) { - bool done = false; - switch (requirements.front().getKind()) { - case RequirementKind::Conformance: - // If the second type is a protocol type, we're done. - done = true; - break; - - case RequirementKind::Superclass: - break; - - case RequirementKind::SameType: - // Skip the next same-type constraint. - continue; - - case RequirementKind::WitnessMarker: - done = true; - break; - } - - if (done) - break; - } - }; - skipUnrepresentedRequirements(); - - // Collect all of the generic parameter lists. - SmallVector allGenericParamLists; - for (auto gpList = genericParams; gpList; - gpList = gpList->getOuterParameters()) { - allGenericParamLists.push_back(gpList); - } - std::reverse(allGenericParamLists.begin(), allGenericParamLists.end()); - - // Helpers that diagnose failures when generic requirements mismatch. - bool failed = false; - auto noteFailure =[&]() { - if (failed) - return; - - Out << "Generic requirements don't match all archetypes\n"; - decl->dump(Out); - - Out << "\nGeneric type: " << genericTy->getString() << "\n"; - Out << "Expected requirements: "; - bool first = true; - for (auto gpList : allGenericParamLists) { - for (auto archetype : gpList->getAllArchetypes()) { - for (auto proto : archetype->getConformsTo()) { - if (first) - first = false; - else - Out << ", "; - - Out << archetype->getString() << " : " - << proto->getDeclaredType()->getString(); - } - } - } - Out << "\n"; - - failed = true; - }; - - // Walk through all of the archetypes in the generic parameter lists, - // matching up their conformance requirements with those in the - for (auto gpList : allGenericParamLists) { - for (auto archetype : gpList->getAllArchetypes()) { - // Make sure we have the value witness marker. - if (requirements.empty()) { - noteFailure(); - Out << "Ran out of requirements before we ran out of archetypes\n"; - break; - } - - if (requirements.front().getKind() - == RequirementKind::WitnessMarker) { - auto type = ArchetypeBuilder::mapTypeIntoContext( - dc, - requirements.front().getFirstType()); - if (type->isEqual(archetype)) { - requirements = requirements.slice(1); - skipUnrepresentedRequirements(); - } else { - noteFailure(); - Out << "Value witness marker for " << type->getString() - << " does not match expected " << archetype->getString() - << "\n"; - } - } else { - noteFailure(); - Out << "Missing value witness marker for " - << archetype->getString() << "\n"; - } - - for (auto proto : archetype->getConformsTo()) { - // If there are no requirements left, we're missing requirements. - if (requirements.empty()) { - noteFailure(); - Out << "No requirement for " << archetype->getString() - << " : " << proto->getDeclaredType()->getString() << "\n"; - continue; - } - - auto firstReqType = ArchetypeBuilder::mapTypeIntoContext( - dc, - requirements.front().getFirstType()); - auto secondReqType = ArchetypeBuilder::mapTypeIntoContext( - dc, - requirements.front().getSecondType()); - - // If the requirements match up, move on to the next requirement. - if (firstReqType->isEqual(archetype) && - secondReqType->isEqual(proto->getDeclaredType())) { - requirements = requirements.slice(1); - skipUnrepresentedRequirements(); - continue; - } - - noteFailure(); - - // If the requirements don't match up, complain. - if (!firstReqType->isEqual(archetype)) { - Out << "Mapped archetype " << firstReqType->getString() - << " does not match expected " << archetype->getString() - << "\n"; - continue; - } - - Out << "Mapped conformance " << secondReqType->getString() - << " does not match expected " - << proto->getDeclaredType()->getString() << "\n"; - } - } - } - - if (!requirements.empty()) { - noteFailure(); - Out << "Extra requirement " - << requirements.front().getFirstType()->getString() - << " : " - << requirements.front().getSecondType()->getString() - << "\n"; - } - - if (failed) - abort(); - } - void verifyChecked(AbstractFunctionDecl *AFD) { PrettyStackTraceDecl debugStack("verifying AbstractFunctionDecl", AFD); @@ -2347,12 +2158,6 @@ struct ASTNodeBase {}; abort(); } - // If the interface type is generic, make sure its requirements - // line up with the archetypes. - if (auto genericTy = interfaceTy->getAs()) { - checkGenericRequirements(AFD, AFD, genericTy); - } - // Throwing @objc methods must have a foreign error convention. if (AFD->isObjC() && static_cast(AFD->getForeignErrorConvention()) From 6a3e9d976f21088de17c856b6046449c6b926013 Mon Sep 17 00:00:00 2001 From: Slava Pestov Date: Sat, 20 Aug 2016 05:11:10 -0700 Subject: [PATCH 3/3] AST: Remove AllArchetypes, NFC --- include/swift/AST/ArchetypeBuilder.h | 5 ---- include/swift/AST/Decl.h | 34 ----------------------- include/swift/AST/GenericSignature.h | 10 +++---- lib/AST/ArchetypeBuilder.cpp | 40 --------------------------- lib/AST/Builtins.cpp | 18 +++++------- lib/AST/Decl.cpp | 41 ---------------------------- lib/ClangImporter/ImportDecl.cpp | 10 ------- lib/Sema/TypeCheckGeneric.cpp | 5 ---- 8 files changed, 11 insertions(+), 152 deletions(-) diff --git a/include/swift/AST/ArchetypeBuilder.h b/include/swift/AST/ArchetypeBuilder.h index 78e8c15882018..84b04581afba5 100644 --- a/include/swift/AST/ArchetypeBuilder.h +++ b/include/swift/AST/ArchetypeBuilder.h @@ -315,11 +315,6 @@ class ArchetypeBuilder { /// parameter. ArchetypeType *getArchetype(GenericTypeParamDecl *GenericParam); - /// \brief Retrieve the array of all of the archetypes produced during - /// archetype assignment. The 'primary' archetypes will occur first in this - /// list. - ArrayRef getAllArchetypes(); - /// Map an interface type to a contextual type. static Type mapTypeIntoContext(const DeclContext *dc, Type type, LazyResolver *resolver = nullptr); diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index 964a2dc927eea..81584a2209356 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -1059,7 +1059,6 @@ class GenericParamList final : unsigned NumParams; SourceLoc WhereLoc; MutableArrayRef Requirements; - ArrayRef AllArchetypes; GenericParamList *OuterParameters; @@ -1120,7 +1119,6 @@ class GenericParamList final : SourceLoc(), getRequirements(), SourceLoc()); - clone->setAllArchetypes(getAllArchetypes()); clone->setOuterParameters(Outer); return clone; } @@ -1199,24 +1197,7 @@ class GenericParamList final : /// main part of a declaration's signature. void addTrailingWhereClause(ASTContext &ctx, SourceLoc trailingWhereLoc, ArrayRef trailingRequirements); - - /// \brief Retrieves the list containing all archetypes described by this - /// generic parameter clause. - /// - /// In this list of archetypes, the primary archetypes come first followed by - /// any non-primary archetypes (i.e., those archetypes that encode associated - /// types of another archetype). - /// - /// This does not include archetypes from the outer generic parameter list(s). - ArrayRef getAllArchetypes() const { return AllArchetypes; } - /// \brief Sets all archetypes *without* copying the source array. - void setAllArchetypes(ArrayRef AA) { - assert(AA.size() >= size() - && "allArchetypes is smaller than number of generic params?!"); - AllArchetypes = AA; - } - /// \brief Retrieve the outer generic parameter list, which provides the /// generic parameters of the context in which this generic parameter list /// exists. @@ -1280,26 +1261,11 @@ class GenericParamList final : TypeSubstitutionMap &subsMap, ArchetypeConformanceMap &conformanceMap) const; - /// Derive the all-archetypes list for the given list of generic - /// parameters. - static ArrayRef - deriveAllArchetypes(ArrayRef params, - SmallVectorImpl &archetypes); - void getForwardingSubstitutionMap(TypeSubstitutionMap &result) const; ArrayRef getForwardingSubstitutions(GenericSignature *sig) const; - /// Collect the nested archetypes of an archetype into the given - /// collection. - /// - /// \param known - the set of archetypes already present in `all` - /// \param all - the output list of archetypes - static void addNestedArchetypes(ArchetypeType *archetype, - SmallPtrSetImpl &known, - SmallVectorImpl &all); - void print(raw_ostream &OS); void dump(); }; diff --git a/include/swift/AST/GenericSignature.h b/include/swift/AST/GenericSignature.h index 6cd223b01377d..9768dbd9ad7a7 100644 --- a/include/swift/AST/GenericSignature.h +++ b/include/swift/AST/GenericSignature.h @@ -184,10 +184,6 @@ class GenericSignature final : public llvm::FoldingSetNode, /// Return a range that iterates through first all of the generic parameters /// of the signature, followed by all of their recursive member types exposed /// through protocol requirements. - /// - /// The member types are presented in the - /// same order as GenericParamList::getAllArchetypes would present for an - /// equivalent GenericParamList. GenericSignatureWitnessIterator getAllDependentTypes() const { return GenericSignatureWitnessIterator(getRequirements()); } @@ -204,8 +200,10 @@ class GenericSignature final : public llvm::FoldingSetNode, /// for mangling purposes. /// /// TODO: This is what getCanonicalSignature() ought to do, but currently - /// cannot due to implementation dependencies on 'getAllDependentTypes' - /// order matching 'getAllArchetypes' order of a generic param list. + /// does not due to former implementation dependencies on + /// 'getAllDependentTypes' order matching 'getAllArchetypes' order of a + /// generic param list. Now that 'getAllArchetypes' is gone, we might + /// be able to move forward here. CanGenericSignature getCanonicalManglingSignature(ModuleDecl &M) const; /// Uniquing for the ASTContext. diff --git a/lib/AST/ArchetypeBuilder.cpp b/lib/AST/ArchetypeBuilder.cpp index 863df986d72f2..3cec048ddac18 100644 --- a/lib/AST/ArchetypeBuilder.cpp +++ b/lib/AST/ArchetypeBuilder.cpp @@ -169,11 +169,6 @@ struct ArchetypeBuilder::Implementation { /// archetypes. llvm::MapVector PotentialArchetypes; - /// A vector containing all of the archetypes, expanded out. - /// FIXME: This notion should go away, because it's impossible to expand - /// out "all" archetypes - SmallVector AllArchetypes; - /// A vector containing the same-type requirements introduced into the /// system. SmallVector SameTypeRequirements; @@ -1761,41 +1756,6 @@ ArchetypeBuilder::getArchetype(GenericTypeParamDecl *GenericParam) { return known->second->getType(*this).getAsArchetype(); } -ArrayRef ArchetypeBuilder::getAllArchetypes() { - // This should be kept in sync with GenericParamList::deriveAllArchetypes(). - if (Impl->AllArchetypes.empty()) { - // Collect the primary archetypes first. - unsigned depth = Impl->PotentialArchetypes.back().first.Depth; - llvm::SmallPtrSet KnownArchetypes; - for (const auto &Entry : Impl->PotentialArchetypes) { - // Skip outer potential archetypes. - if (Entry.first.Depth < depth) - continue; - - PotentialArchetype *PA = Entry.second; - auto Archetype = PA->getType(*this).castToArchetype(); - if (KnownArchetypes.insert(Archetype).second) - Impl->AllArchetypes.push_back(Archetype); - } - - // Collect all of the remaining archetypes. - for (const auto &Entry : Impl->PotentialArchetypes) { - // Skip outer potential archetypes. - if (Entry.first.Depth < depth) - continue; - - PotentialArchetype *PA = Entry.second; - if (!PA->isConcreteType() && !PA->getTypeAliasDecl()) { - auto Archetype = PA->getType(*this).castToArchetype(); - GenericParamList::addNestedArchetypes(Archetype, KnownArchetypes, - Impl->AllArchetypes); - } - } - } - - return Impl->AllArchetypes; -} - ArrayRef ArchetypeBuilder::getSameTypeRequirements() const { return Impl->SameTypeRequirements; diff --git a/lib/AST/Builtins.cpp b/lib/AST/Builtins.cpp index 6ce7b3001d880..5fa68e13d5735 100644 --- a/lib/AST/Builtins.cpp +++ b/lib/AST/Builtins.cpp @@ -423,7 +423,7 @@ static const char * const GenericParamNames[] = { "U", }; -static std::pair +GenericTypeParamDecl * createGenericParam(ASTContext &ctx, const char *name, unsigned index) { Module *M = ctx.TheBuiltinModule; Identifier ident = ctx.getIdentifier(name); @@ -435,26 +435,23 @@ createGenericParam(ASTContext &ctx, const char *name, unsigned index) { new (ctx) GenericTypeParamDecl(&M->getMainFile(FileUnitKind::Builtin), ident, SourceLoc(), 0, index); genericParam->setArchetype(archetype); - return { archetype, genericParam }; + return genericParam; } /// Create a generic parameter list with multiple generic parameters. static GenericParamList *getGenericParams(ASTContext &ctx, unsigned numParameters, - SmallVectorImpl &archetypes, SmallVectorImpl &genericParams) { assert(numParameters <= llvm::array_lengthof(GenericParamNames)); - assert(archetypes.empty() && genericParams.empty()); + assert(genericParams.empty()); for (unsigned i = 0; i != numParameters; ++i) { - auto archetypeAndParam = createGenericParam(ctx, GenericParamNames[i], i); - archetypes.push_back(archetypeAndParam.first); - genericParams.push_back(archetypeAndParam.second); + auto genericParam = createGenericParam(ctx, GenericParamNames[i], i); + genericParams.push_back(genericParam); } auto paramList = GenericParamList::create(ctx, SourceLoc(), genericParams, SourceLoc()); - paramList->setAllArchetypes(ctx.AllocateCopy(archetypes)); return paramList; } @@ -467,7 +464,6 @@ namespace { GenericParamList *TheGenericParamList; SmallVector GenericTypeParams; - SmallVector Archetypes; SmallVector InterfaceParams; SmallVector BodyParams; @@ -479,7 +475,7 @@ namespace { GenericSignatureBuilder(ASTContext &ctx, unsigned numGenericParams = 1) : Context(ctx) { TheGenericParamList = getGenericParams(ctx, numGenericParams, - Archetypes, GenericTypeParams); + GenericTypeParams); } template @@ -512,7 +508,7 @@ namespace { struct ParameterGenerator { unsigned Index; Type build(GenericSignatureBuilder &builder, bool forBody) const { - return (forBody ? builder.Archetypes[Index] + return (forBody ? builder.GenericTypeParams[Index]->getArchetype() : builder.GenericTypeParams[Index]->getDeclaredType()); } }; diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index b2f6866977416..b35852b06654f 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -570,47 +570,6 @@ GenericParamList::getForwardingSubstitutions(GenericSignature *sig) const { return sig->getASTContext().AllocateCopy(result); } -/// \brief Add the nested archetypes of the given archetype to the set -/// of all archetypes. -void GenericParamList::addNestedArchetypes(ArchetypeType *archetype, - SmallPtrSetImpl &known, - SmallVectorImpl &all) { - for (auto nested : archetype->getNestedTypes()) { - auto nestedArch = nested.second.getAsArchetype(); - if (!nestedArch) - continue; - if (known.insert(nestedArch).second) { - assert(!nestedArch->isPrimary() && "Unexpected primary archetype"); - all.push_back(nestedArch); - addNestedArchetypes(nestedArch, known, all); - } - } -} - -ArrayRef -GenericParamList::deriveAllArchetypes(ArrayRef params, - SmallVectorImpl &all) { - // This should be kept in sync with ArchetypeBuilder::getAllArchetypes(). - - assert(all.empty()); - llvm::SmallPtrSet known; - - // Collect all the primary archetypes. - for (auto param : params) { - auto archetype = param->getArchetype(); - if (known.insert(archetype).second) - all.push_back(archetype); - } - - // Collect all the nested archetypes. - for (auto param : params) { - auto archetype = param->getArchetype(); - addNestedArchetypes(archetype, known, all); - } - - return all; -} - TrailingWhereClause::TrailingWhereClause( SourceLoc whereLoc, ArrayRef requirements) diff --git a/lib/ClangImporter/ImportDecl.cpp b/lib/ClangImporter/ImportDecl.cpp index ab6dab441aa02..df667a9d74717 100644 --- a/lib/ClangImporter/ImportDecl.cpp +++ b/lib/ClangImporter/ImportDecl.cpp @@ -5166,8 +5166,6 @@ namespace { auto *archetype = builder.getArchetype(param); param->setArchetype(archetype); } - genericParams->setAllArchetypes( - Impl.SwiftContext.AllocateCopy(builder.getAllArchetypes())); return builder.getGenericSignature(genericParamTypes); } @@ -5669,12 +5667,6 @@ namespace { Type(result->getDeclaredType()), Type(), false); selfDecl->setArchetype(selfArchetype); - - // Set AllArchetypes of the protocol. ObjC protocols don't have associated - // types so only the Self archetype is present. - - result->getGenericParams()->setAllArchetypes( - Impl.SwiftContext.AllocateCopy(llvm::makeArrayRef(selfArchetype))); // Set the generic parameters and requirements. auto genericParam = selfDecl->getDeclaredType() @@ -6967,8 +6959,6 @@ ClangImporter::Implementation::importDeclContextOf( conformsTo, protoArchetype->getSuperclass(), protoArchetype->getIsRecursive()); extSelf->setArchetype(extSelfArchetype); - ext->getGenericParams()->setAllArchetypes( - SwiftContext.AllocateCopy(llvm::makeArrayRef(extSelfArchetype))); auto genericParam = extSelf->getDeclaredType()->castTo(); diff --git a/lib/Sema/TypeCheckGeneric.cpp b/lib/Sema/TypeCheckGeneric.cpp index 3ef28587c5a04..79a9524ccfadf 100644 --- a/lib/Sema/TypeCheckGeneric.cpp +++ b/lib/Sema/TypeCheckGeneric.cpp @@ -495,9 +495,6 @@ void TypeChecker::markInvalidGenericSignature(ValueDecl *VD) { // Wire up the archetypes. for (auto GP : *genericParams) GP->setArchetype(builder.getArchetype(GP)); - - genericParams->setAllArchetypes( - Context.AllocateCopy(builder.getAllArchetypes())); } bool TypeChecker::validateGenericFuncSignature(AbstractFunctionDecl *func) { @@ -808,8 +805,6 @@ void TypeChecker::finalizeGenericParamList(ArchetypeBuilder &builder, if (!GP->hasAccessibility()) GP->setAccessibility(access); } - genericParams->setAllArchetypes( - Context.AllocateCopy(builder.getAllArchetypes())); #ifndef NDEBUG // Record archetype contexts.