swiftlang / swift

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

[SR-8543] UIAppearance doesn't allow generic in whenContainedInInstanceOf: #51061

Open swift-ci opened 6 years ago

swift-ci commented 6 years ago
Previous ID SR-8543
Radar rdar://problem/43888481
Original Reporter nelsonaa (JIRA User)
Type Bug
Additional Detail from JIRA | | | |------------------|-----------------| |Votes | 0 | |Component/s | Compiler | |Labels | Bug, DiagnosticsQoI, TypeChecker | |Assignee | None | |Priority | Medium | md5: 9d0d1fd9f4271291fe10ae1858692db5

Issue Description:

In the following example code it gives an error of 'Cannot assign value of type 'UIColor' to type 'UIColor!' ' It compiles fine without the generic in ExampleController.

import UIKit

final class ExampleController<T>: UITableViewController { }

UITableView.appearance(whenContainedInInstancesOf: [ExampleController.self]).tintColor = UIColor.blue

Ideally generic classes could be used with UIAppearance. However, the error message should at least reflect the real issue.

belkadan commented 6 years ago

Yeah, you'll have to provide a specific ExampleController here, since the generic name "ExampleController" isn't itself a class at run time. You're totally right about the diagnostic, though.

@swift-ci create