Skip to content

Commit 901569c

Browse files
authored
Merge pull request #21303 from DougGregor/runtime-unique-witness-tables-5.0
[5.0] [Runtime] Properly unique foreign witness tables.
2 parents 92596f5 + 7ed5493 commit 901569c

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

stdlib/public/runtime/Metadata.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3669,7 +3669,8 @@ namespace {
36693669
int compareWithKey(const Key other) const {
36703670
if (auto r = comparePointers(other.protocol, key.protocol))
36713671
return r;
3672-
return strcmp(other.type->Name.get(), key.type->Name.get());
3672+
3673+
return TypeContextIdentity(other.type).compare(TypeContextIdentity(key.type));
36733674
}
36743675

36753676
static size_t getExtraAllocationSize(const Key,
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-run-simple-swift
2+
// REQUIRES: executable_test
3+
// REQUIRES: objc_interop
4+
5+
import StdlibUnittest
6+
import Foundation
7+
8+
let conformanceUniquingTests = TestSuite("ConformanceUniquing")
9+
10+
func isSimpleSetAlgebra<T: SetAlgebra>(_: T.Type) -> Bool {
11+
return T.self == T.Element.self
12+
}
13+
14+
// rdar://problem/46685973
15+
conformanceUniquingTests.test("Nested types with the same name") {
16+
expectTrue(isSimpleSetAlgebra(NSData.WritingOptions.self))
17+
expectTrue(isSimpleSetAlgebra(JSONSerialization.WritingOptions.self))
18+
}
19+
20+
runAllTests()

0 commit comments

Comments
 (0)