> On Feb 21, 2017, at 11:34 PM, Adrian Zubarev via swift-evolution 
> <[email protected]> wrote:
> 
> I’d love if we could extend the idea even further. It would be great to be 
> able to extend the typealias type, because it can be a more constrained type 
> (with a where clause).
> 
> protocol P {
>     associatedtype Q
> }
> class C {}
> 
> typealias CP = C & P where Q == Int
> 
> extension CP { … }
> This would make a lot of constrained extension vanish.
> 
> 

Once we have generalized existentials, it should be possible to make something 
like the above desugar into a constrained extension.

Slava
> 
> 
> 
> -- 
> Adrian Zubarev
> Sent with Airmail
> 
> Am 22. Februar 2017 um 08:26:33, David Hart via swift-evolution 
> ([email protected] <mailto:[email protected]>) schrieb:
> 
>> Yes, but it's not very discoverable. Plus, if the subclass existentials 
>> proposal is accepted, it would actually allow us to do:
>> 
>> class C {}
>> extension C & P1 {}
>> 
>> On 22 Feb 2017, at 08:06, Jacob Bandes-Storch <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>>> This works today:
>>> 
>>> protocol P1{}
>>> protocol P2{}
>>> 
>>> extension P1 where Self: P2 {
>>>     func foo() {}
>>> }
>>> 
>>> func bar(x: P1 & P2) {
>>>     x.foo()
>>> }
>>> 
>>> 
>>> On Tue, Feb 21, 2017 at 10:53 PM, David Hart via swift-evolution 
>>> <[email protected] <mailto:[email protected]>> wrote:
>>> Hello list,
>>> 
>>> Found out yesterday that you can’t extend all existentials in Swift:
>>> 
>>> protocol P1 {}
>>> extension P1 {}
>>> // works as expected
>>> 
>>> protocol P2 {}
>>> extension P1 & P2 {}
>>> // error: non-nominal type 'P1 & P2' cannot be extended
>>> 
>>> extension Any {}
>>> // error: non-nominal type 'Any' cannot be extended
>>> 
>>> extension AnyObject {}
>>> // error: 'AnyObject' protocol cannot be extended
>>> 
>>> I’d like to write a proposal to lift some of those restrictions. But the 
>>> question is: which should be lifted? P1 & P2 seems like an obvious case. 
>>> But what about Any and AnyObject? Is there a design reason that we 
>>> shouldn’t allow it?
>>> 
>>> David.
>>> 
>>> _______________________________________________
>>> swift-evolution mailing list
>>> [email protected] <mailto:[email protected]>
>>> https://lists.swift.org/mailman/listinfo/swift-evolution 
>>> <https://lists.swift.org/mailman/listinfo/swift-evolution>
>>> 
>>> 
>> _______________________________________________
>> swift-evolution mailing list
>> [email protected]
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> 
> 
> _______________________________________________
> swift-evolution mailing list
> [email protected] <mailto:[email protected]>
> https://lists.swift.org/mailman/listinfo/swift-evolution 
> <https://lists.swift.org/mailman/listinfo/swift-evolution>

_______________________________________________
swift-evolution mailing list
[email protected]
https://lists.swift.org/mailman/listinfo/swift-evolution

Reply via email to