[swift-evolution] extending typealiases

Adrian Zubarev adrian.zubarev at devandartist.com
Mon Feb 6 12:12:46 CST 2017


Okay fine. I’m curious if we ever should be able to extend existentials. (Could be really handy.)

typealias FooView = UIView & Foo

extension FooView {
     func foo() { .. }
}

// vs.
extension UIView where Self : Foo { .. }


-- 
Adrian Zubarev
Sent with Airmail

Am 6. Februar 2017 um 19:06:16, Anton Zhilin (antonyzhilin at gmail.com) schrieb:

If I understand correctly, extension of a typealias should be strictly equivalent to extension of type on the right:

extension Any<class> {
    func foo()
}
And  
Any<...> are not nominal types, so until we additionally allow extensions for non-nominal types, this will not compile.

2017-02-06 20:51 GMT+03:00 Adrian Zubarev via swift-evolution <swift-evolution at swift.org>:

Just imagining the future. Iff this request will made into the language and we had typealias AnyObject = Any<class>, would the following be valid?

extension AnyObject {
    func foo()
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170206/14846504/attachment.html>


More information about the swift-evolution mailing list