Skip to content

Commit afa2440

Browse files
authored
Merge pull request swiftlang#30370 from slavapestov/encapsulate-conformance-descriptor
Runtime: Use accessor method to get TargetWitnessTable::Description
2 parents 000572d + 4bc1d03 commit afa2440

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

include/swift/ABI/Metadata.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1871,11 +1871,16 @@ using ProtocolDescriptor = TargetProtocolDescriptor<InProcess>;
18711871
/// the layout of a witness table is dependent on the protocol being
18721872
/// represented.
18731873
template <typename Runtime>
1874-
struct TargetWitnessTable {
1874+
class TargetWitnessTable {
18751875
/// The protocol conformance descriptor from which this witness table
18761876
/// was generated.
18771877
ConstTargetMetadataPointer<Runtime, TargetProtocolConformanceDescriptor>
18781878
Description;
1879+
1880+
public:
1881+
const TargetProtocolConformanceDescriptor<Runtime> *getDescription() const {
1882+
return Description;
1883+
}
18791884
};
18801885

18811886
using WitnessTable = TargetWitnessTable<InProcess>;

stdlib/public/runtime/AnyHashableSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static const Metadata *findHashableBaseTypeImpl(const Metadata *type) {
8989
return nullptr;
9090
}
9191
// By this point, `type` is known to conform to `Hashable`.
92-
const auto *conformance = witnessTable->Description;
92+
const auto *conformance = witnessTable->getDescription();
9393
const Metadata *baseTypeThatConformsToHashable =
9494
findConformingSuperclass(type, conformance);
9595
HashableConformances.getOrInsert(HashableConformanceKey{type},

stdlib/public/runtime/Casting.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2568,7 +2568,7 @@ MetadataResponse _getBridgedObjectiveCType(
25682568
const Metadata *conformingType,
25692569
const _ObjectiveCBridgeableWitnessTable *wtable) {
25702570
// FIXME: Can we directly reference the descriptor somehow?
2571-
const ProtocolConformanceDescriptor *conformance = wtable->Description;
2571+
const ProtocolConformanceDescriptor *conformance = wtable->getDescription();
25722572
const ProtocolDescriptor *protocol = conformance->getProtocol();
25732573
auto assocTypeRequirement = protocol->getRequirements().begin();
25742574
assert(assocTypeRequirement->Flags.getKind() ==

stdlib/public/runtime/Metadata.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4626,7 +4626,7 @@ swift_getAssociatedTypeWitnessSlowImpl(
46264626
const ProtocolRequirement *assocType) {
46274627
#ifndef NDEBUG
46284628
{
4629-
const ProtocolConformanceDescriptor *conformance = wtable->Description;
4629+
const ProtocolConformanceDescriptor *conformance = wtable->getDescription();
46304630
const ProtocolDescriptor *protocol = conformance->getProtocol();
46314631
auto requirements = protocol->getRequirements();
46324632
assert(assocType >= requirements.begin() &&
@@ -4671,7 +4671,7 @@ swift_getAssociatedTypeWitnessSlowImpl(
46714671
}
46724672

46734673
// Dig out the protocol.
4674-
const ProtocolConformanceDescriptor *conformance = wtable->Description;
4674+
const ProtocolConformanceDescriptor *conformance = wtable->getDescription();
46754675
const ProtocolDescriptor *protocol = conformance->getProtocol();
46764676

46774677
// Extract the mangled name itself.
@@ -4790,7 +4790,7 @@ static const WitnessTable *swift_getAssociatedConformanceWitnessSlowImpl(
47904790
const ProtocolRequirement *assocConformance) {
47914791
#ifndef NDEBUG
47924792
{
4793-
const ProtocolConformanceDescriptor *conformance = wtable->Description;
4793+
const ProtocolConformanceDescriptor *conformance = wtable->getDescription();
47944794
const ProtocolDescriptor *protocol = conformance->getProtocol();
47954795
auto requirements = protocol->getRequirements();
47964796
assert(assocConformance >= requirements.begin() &&

stdlib/public/runtime/MetadataCache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ class MetadataCacheKey {
365365
if (awt == bwt)
366366
return 0;
367367

368-
auto *aDescription = awt->Description;
369-
auto *bDescription = bwt->Description;
368+
auto *aDescription = awt->getDescription();
369+
auto *bDescription = bwt->getDescription();
370370
if (aDescription == bDescription)
371371
return 0;
372372

0 commit comments

Comments
 (0)