@@ -889,6 +889,53 @@ llvm::Error ModuleFile::readGenericRequirementsChecked(
889889 return llvm::Error::success ();
890890}
891891
892+ void ModuleFile::readRequirementSignature (
893+ SmallVectorImpl<Requirement> &requirements,
894+ SmallVectorImpl<ProtocolTypeAlias> &typeAliases,
895+ llvm::BitstreamCursor &Cursor) {
896+ readGenericRequirements (requirements, Cursor);
897+
898+ using namespace decls_block ;
899+
900+ BCOffsetRAII lastRecordOffset (Cursor);
901+ SmallVector<uint64_t , 8 > scratch;
902+ StringRef blobData;
903+
904+ while (true ) {
905+ lastRecordOffset.reset ();
906+ bool shouldContinue = true ;
907+
908+ llvm::BitstreamEntry entry =
909+ fatalIfUnexpected (Cursor.advance (AF_DontPopBlockAtEnd));
910+ if (entry.Kind != llvm::BitstreamEntry::Record)
911+ break ;
912+
913+ scratch.clear ();
914+ unsigned recordID = fatalIfUnexpected (
915+ Cursor.readRecord (entry.ID , scratch, &blobData));
916+ switch (recordID) {
917+ case PROTOCOL_TYPEALIAS: {
918+ uint64_t rawName;
919+ uint64_t rawTypeID;
920+ ProtocolTypeAliasLayout::readRecord (scratch, rawName, rawTypeID);
921+
922+ auto name = getIdentifier (rawName);
923+ auto underlyingType = getType (rawTypeID);
924+
925+ typeAliases.emplace_back (name, underlyingType);
926+ break ;
927+ }
928+ default :
929+ // This record is not part of the protocol requirement signature.
930+ shouldContinue = false ;
931+ break ;
932+ }
933+
934+ if (!shouldContinue)
935+ break ;
936+ }
937+ }
938+
892939void ModuleFile::readAssociatedTypes (
893940 SmallVectorImpl<AssociatedTypeDecl *> &assocTypes,
894941 llvm::BitstreamCursor &Cursor) {
@@ -919,8 +966,10 @@ void ModuleFile::readAssociatedTypes(
919966 }
920967}
921968
922- // / Advances past any records that might be part of a requirement signature.
923- static llvm::Error skipGenericRequirements (llvm::BitstreamCursor &Cursor) {
969+ // / Advances past any records that might be part of a protocol requirement
970+ // / signature, which consists of generic requirements together with protocol
971+ // / typealias records.
972+ static llvm::Error skipRequirementSignature (llvm::BitstreamCursor &Cursor) {
924973 using namespace decls_block ;
925974
926975 BCOffsetRAII lastRecordOffset (Cursor);
@@ -940,6 +989,7 @@ static llvm::Error skipGenericRequirements(llvm::BitstreamCursor &Cursor) {
940989 switch (maybeRecordID.get ()) {
941990 case GENERIC_REQUIREMENT:
942991 case LAYOUT_REQUIREMENT:
992+ case PROTOCOL_TYPEALIAS:
943993 break ;
944994
945995 default :
@@ -3611,7 +3661,7 @@ class DeclDeserializer {
36113661
36123662 proto->setLazyRequirementSignature (&MF,
36133663 MF.DeclTypeCursor .GetCurrentBitNo ());
3614- if (llvm::Error Err = skipGenericRequirements (MF.DeclTypeCursor ))
3664+ if (llvm::Error Err = skipRequirementSignature (MF.DeclTypeCursor ))
36153665 MF.fatal (std::move (Err));
36163666
36173667 proto->setLazyAssociatedTypeMembers (&MF,
@@ -6755,10 +6805,11 @@ void ModuleFile::finishNormalConformance(NormalProtocolConformance *conformance,
67556805
67566806void ModuleFile::loadRequirementSignature (const ProtocolDecl *decl,
67576807 uint64_t contextData,
6758- SmallVectorImpl<Requirement> &reqs) {
6808+ SmallVectorImpl<Requirement> &reqs,
6809+ SmallVectorImpl<ProtocolTypeAlias> &typeAliases) {
67596810 BCOffsetRAII restoreOffset (DeclTypeCursor);
67606811 fatalIfNotSuccess (DeclTypeCursor.JumpToBit (contextData));
6761- readGenericRequirements (reqs, DeclTypeCursor);
6812+ readRequirementSignature (reqs, typeAliases , DeclTypeCursor);
67626813}
67636814
67646815void ModuleFile::loadAssociatedTypes (const ProtocolDecl *decl,
0 commit comments