Skip to content

Commit 5eed9d8

Browse files
committed
[NCGenerics] fix serialization of PCT
resolves rdar://118947007
1 parent 488e0dd commit 5eed9d8

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

lib/Serialization/Deserialization.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6919,11 +6919,15 @@ DESERIALIZE_TYPE(GENERIC_TYPE_PARAM_TYPE)(
69196919

69206920
Expected<Type> DESERIALIZE_TYPE(PROTOCOL_COMPOSITION_TYPE)(
69216921
ModuleFile &MF, SmallVectorImpl<uint64_t> &scratch, StringRef blobData) {
6922-
bool hasExplicitAnyObject;
6922+
bool hasExplicitAnyObject, hasInverseCopyable;
69236923
ArrayRef<uint64_t> rawProtocolIDs;
69246924

69256925
decls_block::ProtocolCompositionTypeLayout::readRecord(
6926-
scratch, hasExplicitAnyObject, rawProtocolIDs);
6926+
scratch,
6927+
hasExplicitAnyObject,
6928+
hasInverseCopyable,
6929+
rawProtocolIDs);
6930+
69276931
SmallVector<Type, 4> protocols;
69286932
for (TypeID protoID : rawProtocolIDs) {
69296933
auto protoTy = MF.getTypeChecked(protoID);
@@ -6932,7 +6936,11 @@ Expected<Type> DESERIALIZE_TYPE(PROTOCOL_COMPOSITION_TYPE)(
69326936
protocols.push_back(protoTy.get());
69336937
}
69346938

6935-
return ProtocolCompositionType::get(MF.getContext(), protocols,
6939+
InvertibleProtocolSet inverses;
6940+
if (hasInverseCopyable)
6941+
inverses.insert(InvertibleProtocolKind::Copyable);
6942+
6943+
return ProtocolCompositionType::get(MF.getContext(), protocols, inverses,
69366944
hasExplicitAnyObject);
69376945
}
69386946

lib/Serialization/ModuleFormat.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5858
/// describe what change you made. The content of this comment isn't important;
5959
/// it just ensures a conflict if two people change the module format.
6060
/// Don't worry about adhering to the 80-column limit for this line.
61-
const uint16_t SWIFTMODULE_VERSION_MINOR = 821; // extractConstantsFromMembers
61+
const uint16_t SWIFTMODULE_VERSION_MINOR = 822; // ~Copyable
6262

6363
/// A standard hash seed used for all string hashes in a serialized module.
6464
///
@@ -1270,6 +1270,7 @@ namespace decls_block {
12701270
TYPE_LAYOUT(ProtocolCompositionTypeLayout,
12711271
PROTOCOL_COMPOSITION_TYPE,
12721272
BCFixed<1>, // has AnyObject constraint
1273+
BCFixed<1>, // has ~Copyable
12731274
BCArray<TypeIDField> // protocols
12741275
);
12751276

lib/Serialization/Serialization.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5564,11 +5564,21 @@ class Serializer::TypeSerializer : public TypeVisitor<TypeSerializer> {
55645564
for (auto proto : composition->getMembers())
55655565
protocols.push_back(S.addTypeRef(proto));
55665566

5567+
bool inverseCopyable = false;
5568+
for (auto ip : composition->getInverses()) {
5569+
switch (ip) {
5570+
case InvertibleProtocolKind::Copyable:
5571+
inverseCopyable = true;
5572+
break;
5573+
};
5574+
}
5575+
55675576
unsigned abbrCode =
55685577
S.DeclTypeAbbrCodes[ProtocolCompositionTypeLayout::Code];
55695578
ProtocolCompositionTypeLayout::emitRecord(
55705579
S.Out, S.ScratchRecord, abbrCode,
55715580
composition->hasExplicitAnyObject(),
5581+
inverseCopyable,
55725582
protocols);
55735583
}
55745584

0 commit comments

Comments
 (0)