     /// storing it to the referenced memory.
     @_transparent nonmutating set {
       // Autorelease the object reference.
-      typealias OptionalAnyObject = AnyObject?
-      let newAnyObject = unsafeBitCast(newValue, to: OptionalAnyObject.self)
-      Builtin.retain(newAnyObject)
-      Builtin.autorelease(newAnyObject)
-      // Trivially assign it as an OpaquePointer; the pointer references an
-      // autoreleasing slot, so retains/releases of the original value are
-      // unneeded.
-      typealias OptionalUnmanaged = Unmanaged<AnyObject>?
-      UnsafeMutablePointer<Pointee>(_rawValue).withMemoryRebound(
-        to: OptionalUnmanaged.self, capacity: 1) {
-        if let newAnyObject = newAnyObject {
-          $0.pointee = Unmanaged.passUnretained(newAnyObject)
-        }
-        else {
-          $0.pointee = nil
-        }
+      let object = unsafeBitCast(newValue, to: Optional<AnyObject>.self)
+      Builtin.retain(object)
+      Builtin.autorelease(object)
+
+      // Convert it to an unmanaged reference and trivially assign it to the
+      // memory addressed by this pointer.
+      let unmanaged: Optional<Unmanaged<AnyObject>>
+      if let object = object {
+        unmanaged = Unmanaged.passUnretained(object)
+      } else {
+        unmanaged = nil
       }
+      UnsafeMutableRawPointer(_rawValue).storeBytes(
+        of: unmanaged,
+        as: Optional<Unmanaged<AnyObject>>.self)
     }
   }
 

  public var pointee: Pointee {
    /// Retrieve the value the pointer points to.
    @_transparent get {
      // We can do a strong load normally.
      return UnsafePointer(self).pointee
    }
    /// Set the value the pointer points to, copying over the previous value.
    ///
    /// AutoreleasingUnsafeMutablePointers are assumed to reference a

  public subscript(i: Int) -> Pointee {
    @_transparent
    get {
      return self.advanced(by: i).pointee
    }
  }

