Skip to content

[Runtime] Properly unique foreign witness tables. #21302

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion stdlib/public/runtime/Metadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3669,7 +3669,8 @@ namespace {
int compareWithKey(const Key other) const {
if (auto r = comparePointers(other.protocol, key.protocol))
return r;
return strcmp(other.type->Name.get(), key.type->Name.get());

return TypeContextIdentity(other.type).compare(TypeContextIdentity(key.type));
}

static size_t getExtraAllocationSize(const Key,
Expand Down
20 changes: 20 additions & 0 deletions test/Runtime/conformance_uniquing.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: objc_interop

import StdlibUnittest
import Foundation

let conformanceUniquingTests = TestSuite("ConformanceUniquing")

func isSimpleSetAlgebra<T: SetAlgebra>(_: T.Type) -> Bool {
return T.self == T.Element.self
}

// rdar://problem/46685973
conformanceUniquingTests.test("Nested types with the same name") {
expectTrue(isSimpleSetAlgebra(NSData.WritingOptions.self))
expectTrue(isSimpleSetAlgebra(JSONSerialization.WritingOptions.self))
}

runAllTests()