Skip to content

Commit 43d7b75

Browse files
committed
Foundation: extract cfSource from RunLoop._Source
Making `cfSource` a member within the structure prevents allowing overriding of the `open` class as the type it returns cannot be deserialised. Because the member is not a stored property, extract it to an extension which removes it from the vtable. This allows the use of the private type in an external context.
1 parent 2dce195 commit 43d7b75

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Sources/Foundation/RunLoop.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -327,8 +327,6 @@ extension RunLoop {
327327
@available(*, deprecated, message: "For XCTest use only.")
328328
open class _Source: NSObject {
329329
fileprivate var _cfSourceStorage: AnyObject!
330-
fileprivate var cfSource: CFRunLoopSource { unsafeBitCast(_cfSourceStorage, to: CFRunLoopSource.self) }
331-
332330

333331
public init(order: Int = 0) {
334332
super.init()
@@ -410,3 +408,9 @@ extension RunLoop {
410408
}
411409
}
412410
}
411+
412+
extension RunLoop._Source {
413+
fileprivate var cfSource: CFRunLoopSource {
414+
unsafeBitCast(_cfSourceStorage, to: CFRunLoopSource.self)
415+
}
416+
}

0 commit comments

Comments
 (0)