swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.37k stars 10.34k forks source link

[SR-6239] Cannot convert value to generic value #48790

Open swift-ci opened 6 years ago

swift-ci commented 6 years ago
Previous ID SR-6239
Radar None
Original Reporter robdashnash (JIRA User)
Type Bug
Environment macOS 10.13 Xcode Version 9.0.1 (9A1004) Swift 4 iMac (Retina 5K, 27-inch, 2017)
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, TypeChecker | |Assignee | @slavapestov | |Priority | Medium | md5: eb4d433304e40a585fd63cfdd5b2135d

Issue Description:

class Event: NSManagedObject {}

class FetchedResultsController<Entity: NSManagedObject>: NSObject {}

final class EventsFetchedResultsController: FetchedResultsController<Event> {}

struct Bubble<Entity: NSManagedObject> {
  let fetchedResultsController: FetchedResultsController<Entity>
}

var bubble: Bubble<Event> = Bubble<Event>(fetchedResultsController: EventsFetchedResultsController()) // Error: Cannot convert value of type 'EventsFetchedResultsController' to expected argument type 'FetchedResultsController<_>
belkadan commented 6 years ago

cc @xedin, @rudkx

slavapestov commented 6 years ago

Objective-C generics allow you to cast between different instantiations of the same generic type, but the cast warnings don't know this. I have some dupes of this and am planning on looking at it later.

swift-ci commented 5 years ago

Comment by Rob Nash (JIRA)

What does AM / PM mean in your comments ? : - 0