remove warnings when calling unsafeBitCast()

This commit is contained in:
John Estropia
2017-03-09 18:59:37 +09:00
parent f21e4e12e0
commit fe25a9aa36
4 changed files with 58 additions and 3 deletions

View File

@@ -677,7 +677,12 @@ public final class ListMonitor<T: NSManagedObject>: Hashable {
internal func downcast() -> ListMonitor<NSManagedObject> {
return unsafeBitCast(self, to: ListMonitor<NSManagedObject>.self)
@inline(__always)
func noWarnUnsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
return unsafeBitCast(x, to: type)
}
return noWarnUnsafeBitCast(self, to: ListMonitor<NSManagedObject>.self)
}
internal func registerChangeNotification(_ notificationKey: UnsafeRawPointer, name: Notification.Name, toObserver observer: AnyObject, callback: @escaping (_ monitor: ListMonitor<T>) -> Void) {

View File

@@ -110,11 +110,21 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
return lhs === rhs
}
public static func == <T: NSManagedObject, U: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<U>) -> Bool {
return lhs.fetchedResultsController === rhs.fetchedResultsController
}
public static func ~= <T: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<T>) -> Bool {
return lhs === rhs
}
public static func ~= <T: NSManagedObject, U: NSManagedObject>(lhs: ObjectMonitor<T>, rhs: ObjectMonitor<U>) -> Bool {
return lhs.fetchedResultsController === rhs.fetchedResultsController
}
// MARK: Hashable
@@ -212,7 +222,12 @@ public final class ObjectMonitor<EntityType: NSManagedObject>: Equatable {
internal func downcast() -> ObjectMonitor<NSManagedObject> {
return unsafeBitCast(self, to: ObjectMonitor<NSManagedObject>.self)
@inline(__always)
func noWarnUnsafeBitCast<T, U>(_ x: T, to type: U.Type) -> U {
return unsafeBitCast(x, to: type)
}
return noWarnUnsafeBitCast(self, to: ObjectMonitor<NSManagedObject>.self)
}
deinit {