Merge pull request #7227 from apple/revert-7116-unsafeBitCast-Runtime.swift.gyb
diff --git a/stdlib/public/core/NewtypeWrapper.swift.gyb b/stdlib/public/core/NewtypeWrapper.swift.gyb
index 2e1e59d..0fbdf51 100644
--- a/stdlib/public/core/NewtypeWrapper.swift.gyb
+++ b/stdlib/public/core/NewtypeWrapper.swift.gyb
@@ -23,7 +23,7 @@
% for op in ['<', '>', '<=', '>=']:
public func ${op} <T: _SwiftNewtypeWrapper>(lhs: T, rhs: T) -> Bool
- where T.RawValue : Comparable {
+ where T : Comparable, T.RawValue : Comparable {
return lhs.rawValue ${op} rhs.rawValue
}
% end
diff --git a/test/ClangImporter/newtype_conformance.swift b/test/ClangImporter/newtype_conformance.swift
new file mode 100644
index 0000000..5dd60ce
--- /dev/null
+++ b/test/ClangImporter/newtype_conformance.swift
@@ -0,0 +1,28 @@
+// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -typecheck -I %S/Inputs/custom-modules %s
+// REQUIRES: objc_interop
+
+// This test can't use '-verify' mode, because the potential error wouldn't
+// belong to any file.
+// e.g.:
+// <unknown>:0: error: type 'NSNotification.Name' does not conform to protocol 'Comparable'
+
+import Foundation
+
+func acceptEquatable<T: Equatable>(_: T) {}
+func acceptHashable<T: Hashable>(_: T) {}
+func acceptComparable<T: Comparable>(_: T) {}
+
+func testNewTypeWrapperComparable(x: NSNotification.Name, y: NSNotification.Name) {
+ acceptEquatable(x)
+ acceptHashable(x)
+ acceptComparable(x)
+
+ _ = x == y
+ _ = x != y
+ _ = x.hashValue
+ _ = x < y
+ _ = x > y
+ _ = x <= y
+ _ = x >= y
+ _ = x as NSString
+}