Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-08 Thread C. Keith Ray via swift-users
good point - type safety would prevent it from compiling. also, the controllers are subclasses of NSFetchedResultsController but the delegate method takes a different type: NSFetchedResultsController NSManagedObject != NSFetchRequestResult -- C. Keith Ray Senior Software Engineer /

Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-07 Thread Glen Huang via swift-users
Works like a charm, thanks. > On 7 Oct 2017, at 2:56 PM, Slava Pestov wrote: > > You can try upcasting the value to NSObject first, and then performing a > conditional downcast to Controller1 and Controller2. At this point the type > checker will not have enough information

Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-07 Thread Slava Pestov via swift-users
You can try upcasting the value to NSObject first, and then performing a conditional downcast to Controller1 and Controller2. At this point the type checker will not have enough information to decide that the cast always fails, and should no longer emit a warning. Slava > On Oct 6, 2017, at

Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-07 Thread Glen Huang via swift-users
Done, https://bugs.swift.org/browse/SR-6083 In the mean time, is there any workaround? Or it’s not possible to check the concrete type without this issue being fixed? > On 7 Oct 2017, at 2:44 PM, Slava Pestov wrote: > > Oh I see. I

Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-07 Thread Slava Pestov via swift-users
Oh I see. I think the problem is that with Objective-C generics, you can always cast from Foo to Foo, because the type parameters do not really exist. Swift’s type checking logic for casts assumes Swift generic semantics, where in general Foo and Foo are unrelated types. Do you mind filing a

Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-07 Thread Glen Huang via swift-users
NSFetchedResultsController is the class from Core Data: https://developer.apple.com/documentation/coredata/nsfetchedresultscontroller > On 7 Oct 2017, at 2:38 PM, Slava Pestov wrote: > > Can you post a self-contained example, including the declaration of >

Re: [swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-07 Thread Slava Pestov via swift-users
Can you post a self-contained example, including the declaration of NSFetchedResultsController? Slava > On Oct 6, 2017, at 11:28 PM, Glen Huang via swift-users > wrote: > > Hi, > > I defined some concrete classes inheriting from a generic class like this: > > class

[swift-users] How to check the type of a concrete class that inherits from a generic class?

2017-10-07 Thread Glen Huang via swift-users
Hi, I defined some concrete classes inheriting from a generic class like this: class Controller1: NSFetchedResultsController {} class Controller2: NSFetchedResultsController {} And I assign them a shared delegate, and in the delegate method: func controllerWillChangeContent(_ controller: