Skip to content

Commit 67393a5

Browse files
committed
[Runtime] Add a means to obtain a conformance descriptor.
For protocol conformance demangling, we will need to be able to fetch a ProtocolConformanceDescriptor given a protocol and a type that might conform to that protocol. Add a function to do that, as well as a cache for that function's results. rdar://46280860
1 parent aa89925 commit 67393a5

File tree

3 files changed

+302
-26
lines changed

3 files changed

+302
-26
lines changed

stdlib/public/CompatibilityOverride/CompatibilityOverrideRuntime.def

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,12 @@ OVERRIDE_FOREIGN(dynamicCastForeignClassUnconditional, const void *, , , swift::
217217

218218
#endif
219219

220+
OVERRIDE_PROTOCOLCONFORMANCE(getConformanceDescriptor,
221+
const ProtocolConformanceDescriptor *, , , swift::,
222+
(const Metadata * const type,
223+
const ProtocolDescriptor *protocol),
224+
(type, protocol))
225+
220226
#undef OVERRIDE
221227
#undef OVERRIDE_METADATALOOKUP
222228
#undef OVERRIDE_CASTING

stdlib/public/runtime/Private.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,17 @@ class TypeInfo {
643643
id _quickLookObjectForPointer(void *value);
644644
#endif
645645

646+
/// Retrieve a conformance descriptor given a type and protocol.
647+
/// Note that this DOES NOT take into account generic arguments.
648+
///
649+
/// \param type The type we're considering.
650+
/// \param protocol The protocol to which the type may conform.
651+
///
652+
/// \returns a protocol conformance descriptor, or nullptr if none found.
653+
const ProtocolConformanceDescriptor *
654+
swift_getConformanceDescriptor(const Metadata * const type,
655+
const ProtocolDescriptor *protocol);
656+
646657
} // end namespace swift
647658

648659
#endif /* SWIFT_RUNTIME_PRIVATE_H */

0 commit comments

Comments
 (0)