From b6da135ea0eb48a1e2c0dd7c8a296a99d2b814c7 Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Wed, 13 Jul 2016 19:37:22 -0700 Subject: [PATCH] Add 'bitPattern:' label to '(U)Int.init(ObjectIdentifier)' SR-2064 rdar://27327186 --- stdlib/public/core/Reflection.swift | 22 ++++++++++++++++++---- test/1_stdlib/Runtime.swift.gyb | 5 ++++- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/stdlib/public/core/Reflection.swift b/stdlib/public/core/Reflection.swift index 4091109b6035a..795a4f72c47b6 100644 --- a/stdlib/public/core/Reflection.swift +++ b/stdlib/public/core/Reflection.swift @@ -48,7 +48,7 @@ extension ObjectIdentifier : CustomDebugStringConvertible { } public func <(lhs: ObjectIdentifier, rhs: ObjectIdentifier) -> Bool { - return UInt(lhs) < UInt(rhs) + return UInt(bitPattern: lhs) < UInt(bitPattern: rhs) } public func ==(x: ObjectIdentifier, y: ObjectIdentifier) -> Bool { @@ -57,15 +57,15 @@ public func ==(x: ObjectIdentifier, y: ObjectIdentifier) -> Bool { extension UInt { /// Create a `UInt` that captures the full value of `objectID`. - public init(_ objectID: ObjectIdentifier) { + public init(bitPattern objectID: ObjectIdentifier) { self.init(Builtin.ptrtoint_Word(objectID._value)) } } extension Int { /// Create an `Int` that captures the full value of `objectID`. - public init(_ objectID: ObjectIdentifier) { - self.init(bitPattern: UInt(objectID)) + public init(bitPattern objectID: ObjectIdentifier) { + self.init(bitPattern: UInt(bitPattern: objectID)) } } @@ -631,3 +631,17 @@ extension ObjectIdentifier { Builtin.unreachable() } } + +extension UInt { + @available(*, unavailable, renamed: "init(bitPattern:)") + public init(_ objectID: ObjectIdentifier) { + Builtin.unreachable() + } +} + +extension Int { + @available(*, unavailable, renamed: "init(bitPattern:)") + public init(_ objectID: ObjectIdentifier) { + Builtin.unreachable() + } +} diff --git a/test/1_stdlib/Runtime.swift.gyb b/test/1_stdlib/Runtime.swift.gyb index 134dfb8039c18..1c137b4740f29 100644 --- a/test/1_stdlib/Runtime.swift.gyb +++ b/test/1_stdlib/Runtime.swift.gyb @@ -995,8 +995,11 @@ Reflection.test("ObjectIdentifier/CustomDebugStringConvertible") { expectEqual(String(reflecting: oi1), String(reflecting: oi1)) expectNotEqual(String(reflecting: oi1), String(reflecting: oi2)) - let p1 = UnsafePointer(bitPattern: UInt(oi1))! + let p1 = UnsafePointer(bitPattern: UInt(bitPattern: oi1))! expectPrinted("ObjectIdentifier(\(p1))", oi1) + let p2 = UnsafePointer(bitPattern: Int(bitPattern: oi1))! + expectPrinted("ObjectIdentifier(\(p2))", oi1) + } Reflection.test("CustomMirrorIsInherited") {