@@ -265,11 +265,11 @@ internal func _stdlib_NSObject_isEqual(_ lhs: AnyObject, _ rhs: AnyObject) -> Bo
265
265
/// Like `UnsafeMutablePointer<Unmanaged<AnyObject>>`, or `id
266
266
/// __unsafe_unretained *` in Objective-C ARC.
267
267
internal struct _UnmanagedAnyObjectArray {
268
- /// Underlying pointer, Unmanaged to escape reference counting .
269
- internal var value: UnsafeMutablePointer<Unmanaged<AnyObject>>
268
+ /// Underlying pointer.
269
+ internal var value: UnsafeMutableRawPointer
270
270
271
271
internal init(_ up: UnsafeMutablePointer<AnyObject>) {
272
- self.value = UnsafeMutablePointer (up)
272
+ self.value = UnsafeMutableRawPointer (up)
273
273
}
274
274
275
275
internal init?(_ up: UnsafeMutablePointer<AnyObject>?) {
@@ -279,10 +279,16 @@ internal struct _UnmanagedAnyObjectArray {
279
279
280
280
internal subscript(i: Int) -> AnyObject {
281
281
get {
282
- return value[i].takeUnretainedValue()
282
+ let unmanaged = value.load(
283
+ fromByteOffset: i * strideof(AnyObject.self),
284
+ as: Unmanaged<AnyObject>.self)
285
+ return unmanaged.takeUnretainedValue()
283
286
}
284
287
nonmutating set(newValue) {
285
- value[i] = Unmanaged.passUnretained(newValue)
288
+ let unmanaged = Unmanaged.passUnretained(newValue)
289
+ value.storeBytes(of: unmanaged,
290
+ toByteOffset: i * strideof(AnyObject.self),
291
+ as: Unmanaged<AnyObject>.self)
286
292
}
287
293
}
288
294
}
0 commit comments