[swift-evolution] Swift Generic Subclass Type System Problem
Cao Jiannan
frogcjn_icloud at icloud.com
Mon Feb 15 21:34:20 CST 2016
Hi all,
I want to discuss on optional generic sub-typing problem.
Here is a protocol type for some UIViewController,
protocol SegueHandlerType {
var tableView: UITableView! { get }
}
so the UITableViewController can conform to the protocal
extension UITableViewController : SegueHandlerType {
}
It's great!
What if the tableView is a subclass UITableView?
like:
class MyTableView : UITableView {
}
MyTableViewController {
@IBOutlet var tableView: MyTableView!
}
Then
extension MyTableViewController:SegueHandlerType {
}
will trigger a compiler error.
So the Optional needs a subclass system.
Or to say, that the template system needs a subclass system.
Optional<UITableView> should be the super class of Optional<MyTableView>
Array<UITableView> should be the super class of Array<MyTableView>
https://forums.developer.apple.com/message/101646#101646 <https://forums.developer.apple.com/message/101646#101646>
Also, I think, if B is subclass of A
Either<B,B> is subclass of Either<A,A>, Either<A,B>, Either<B,A>
Either<B,A> is subclass of Either<A,A>
Either<A,B> is subclass of Either<A,A>
Thanks!
Jiannan, Cao
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160216/44d2ff33/attachment.html>
More information about the swift-evolution
mailing list