<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Done, <a href="https://bugs.swift.org/browse/SR-6083" class="">https://bugs.swift.org/browse/SR-6083</a><div class=""><br class=""></div><div class="">In the mean time, is there any workaround? Or it’s not possible to check the concrete type without this issue being fixed?<br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On 7 Oct 2017, at 2:44 PM, Slava Pestov <<a href="mailto:spestov@apple.com" class="">spestov@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Oh I see. I think the problem is that with Objective-C generics, you can always cast from Foo<A> to Foo<B>, because the type parameters do not really exist. Swift’s type checking logic for casts assumes Swift generic semantics, where in general Foo<A> and Foo<B> are unrelated types.<br class=""><br class="">Do you mind filing a bug?<br class=""><br class="">Slava<br class=""><br class=""><blockquote type="cite" class="">On Oct 6, 2017, at 11:40 PM, Glen Huang <<a href="mailto:heyhgl@gmail.com" class="">heyhgl@gmail.com</a>> wrote:<br class=""><br class="">NSFetchedResultsController is the class from Core Data: <br class=""><br class=""><a href="https://developer.apple.com/documentation/coredata/nsfetchedresultscontroller" class="">https://developer.apple.com/documentation/coredata/nsfetchedresultscontroller</a><br class=""><br class=""><blockquote type="cite" class="">On 7 Oct 2017, at 2:38 PM, Slava Pestov <spestov@apple.com> wrote:<br class=""><br class="">Can you post a self-contained example, including the declaration of NSFetchedResultsController?<br class=""><br class="">Slava<br class=""><br class=""><blockquote type="cite" class="">On Oct 6, 2017, at 11:28 PM, Glen Huang via swift-users <swift-users@swift.org> wrote:<br class=""><br class="">Hi,<br class=""><br class="">I defined some concrete classes inheriting from a generic class like this:<br class=""><br class="">class Controller1: NSFetchedResultsController<NSManagedObject> {}<br class="">class Controller2: NSFetchedResultsController<NSManagedObject> {}<br class=""><br class="">And I assign them a shared delegate, and in the delegate method:<br class=""><br class="">func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>)<br class=""><br class="">I want to test the concrete type of controller, doing things differently for Controller1 and Controller2.<br class=""><br class="">But doing the following gives me a warning: Cast from 'NSFetchedResultsController<NSFetchRequestResult>' to unrelated type 'Controller1’ always fails<br class=""><br class="">switch controller {<br class="">case is Controller1:<br class=""> // ...<br class="">default:<br class=""> break<br class="">}<br class=""><br class="">I wonder what’s the correct way to check the concrete type?<br class=""><br class="">Regards,<br class="">Glen<br class="">_______________________________________________<br class="">swift-users mailing list<br class="">swift-users@swift.org<br class="">https://lists.swift.org/mailman/listinfo/swift-users<br class=""></blockquote><br class=""></blockquote><br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div></body></html>