Skip to content

Commit 806cf57

Browse files
authored
Merge pull request #20825 from DougGregor/runtime-override-conforms-to-swift-protocol
2 parents 2889a1f + da772e9 commit 806cf57

File tree

4 files changed

+21
-6
lines changed

4 files changed

+21
-6
lines changed

stdlib/public/runtime/CompatibilityOverride.def

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ OVERRIDE_PROTOCOLCONFORMANCE(conformsToProtocol, const WitnessTable *, , swift::
130130
const ProtocolDescriptor *protocol),
131131
(type, protocol))
132132

133+
OVERRIDE_PROTOCOLCONFORMANCE(conformsToSwiftProtocol,
134+
const ProtocolConformanceDescriptor *, , swift::,
135+
(const Metadata * const type,
136+
const ProtocolDescriptor *protocol,
137+
StringRef moduleName),
138+
(type, protocol, moduleName))
139+
133140
OVERRIDE_KEYPATH(getKeyPath, const HeapObject *, , swift::,
134141
(const void *pattern, const void *arguments),
135142
(pattern, arguments))

stdlib/public/runtime/Private.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,8 +510,9 @@ class TypeInfo {
510510
/// Determine whether the given type conforms to the given Swift protocol,
511511
/// returning the appropriate protocol conformance descriptor when it does.
512512
const ProtocolConformanceDescriptor *
513-
_conformsToSwiftProtocol(const Metadata * const type,
514-
const ProtocolDescriptor *protocol);
513+
swift_conformsToSwiftProtocol(const Metadata * const type,
514+
const ProtocolDescriptor *protocol,
515+
StringRef module);
515516

516517
/// Retrieve an associated type witness from the given witness table.
517518
///

stdlib/public/runtime/ProtocolConformance.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -532,9 +532,10 @@ namespace {
532532
};
533533
}
534534

535-
const ProtocolConformanceDescriptor *
536-
swift::_conformsToSwiftProtocol(const Metadata * const type,
537-
const ProtocolDescriptor *protocol) {
535+
static const ProtocolConformanceDescriptor *
536+
swift_conformsToSwiftProtocolImpl(const Metadata * const type,
537+
const ProtocolDescriptor *protocol,
538+
StringRef module) {
538539
auto &C = Conformances.get();
539540

540541
// See if we have a cached conformance. The ConcurrentMap data structure
@@ -600,7 +601,8 @@ swift::_conformsToSwiftProtocol(const Metadata * const type,
600601
static const WitnessTable *
601602
swift_conformsToProtocolImpl(const Metadata * const type,
602603
const ProtocolDescriptor *protocol) {
603-
auto description = _conformsToSwiftProtocol(type, protocol);
604+
auto description =
605+
swift_conformsToSwiftProtocol(type, protocol, StringRef());
604606
if (!description)
605607
return nullptr;
606608

unittests/runtime/CompatibilityOverride.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ TEST_F(CompatibilityOverrideTest, test_swift_conformsToProtocol) {
168168
ASSERT_EQ(Result, nullptr);
169169
}
170170

171+
TEST_F(CompatibilityOverrideTest, test_swift_conformsToSwiftProtocol) {
172+
auto Result = swift_conformsToSwiftProtocol(nullptr, nullptr, StringRef());
173+
ASSERT_EQ(Result, nullptr);
174+
}
175+
171176
TEST_F(CompatibilityOverrideTest, test_swift_getTypeByMangledNode) {
172177
Demangler demangler;
173178
auto Result = swift_getTypeByMangledNode(demangler, nullptr, nullptr,

0 commit comments

Comments
 (0)