Skip to content

Commit 5307f5d

Browse files
committed
[Runtime] Add "reserved" protocol conformance kind and ignore it.
The protocol conformance record has two bits to describe how the witness table will be produced. There are currently three states (direct reference to witness table, witness table accessor, and conditional witness table accessor). Add a reserved case for the fourth state so the Swift 5 runtime will (silently) ignore conformances using that fourth state, when/if some future Swift uses it.
1 parent 598c385 commit 5307f5d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

include/swift/ABI/MetadataValues.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@ enum class ProtocolConformanceReferenceKind : unsigned {
220220
/// table whose conformance is conditional on additional requirements that
221221
/// must first be evaluated and then provided to the accessor function.
222222
ConditionalWitnessTableAccessor,
223+
/// Reserved for future use.
224+
Reserved,
223225
};
224226

225227
// Type metadata record discriminant

include/swift/Runtime/Metadata.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,6 +2665,9 @@ struct TargetProtocolConformanceRecord {
26652665
case ProtocolConformanceReferenceKind::WitnessTableAccessor:
26662666
case ProtocolConformanceReferenceKind::ConditionalWitnessTableAccessor:
26672667
assert(false && "not witness table");
2668+
2669+
case ProtocolConformanceReferenceKind::Reserved:
2670+
break;
26682671
}
26692672
return WitnessTable;
26702673
}
@@ -2673,6 +2676,7 @@ struct TargetProtocolConformanceRecord {
26732676
switch (Flags.getConformanceKind()) {
26742677
case ProtocolConformanceReferenceKind::WitnessTableAccessor:
26752678
case ProtocolConformanceReferenceKind::ConditionalWitnessTableAccessor:
2679+
case ProtocolConformanceReferenceKind::Reserved:
26762680
break;
26772681

26782682
case ProtocolConformanceReferenceKind::WitnessTable:

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ template<> void ProtocolConformanceRecord::dump() const {
9090
printf("conditional witness table accessor %s\n",
9191
symbolName((const void *)(uintptr_t)getWitnessTableAccessor()));
9292
break;
93+
case ProtocolConformanceReferenceKind::Reserved:
94+
printf("reserved witness table kind\n");
95+
break;
9396
}
9497
}
9598
#endif
@@ -165,6 +168,9 @@ const {
165168
typeName.c_str(), demangledProtocolName.c_str());
166169
return nullptr;
167170
}
171+
172+
case ProtocolConformanceReferenceKind::Reserved:
173+
return nullptr;
168174
}
169175

170176
swift_runtime_unreachable(
@@ -591,6 +597,11 @@ swift::swift_conformsToProtocol(const Metadata * const type,
591597
C.cacheSuccess(type, P, record.getWitnessTable(type));
592598
break;
593599

600+
case ProtocolConformanceReferenceKind::Reserved:
601+
// Always fail, because we cannot interpret a future conformance
602+
// kind.
603+
C.cacheFailure(metadata, P);
604+
break;
594605
}
595606
}
596607
}

0 commit comments

Comments
 (0)