Re: [swift-evolution] Self behaves inconsistently in protocol method signatures

2015-12-28 Thread Developer via swift-evolution
That doesn't look like a variance issue to me, that's about the same "information" invariant I talked about before. The former works because self resolves to an invariant type, the type of the implementing structure, which satisfies the requirement Self introduces. The latter does not because

[swift-evolution] Self behaves inconsistently in protocol method signatures

2015-12-28 Thread Matthew Johnson via swift-evolution
I have brought up the idea of a non-covarying Self a few times. I was surprised to realize that Self is actually non-covarying when used for parameters in protocol declarations! Here is an example demonstrating this: protocol P { func foo(s: Self) } protocol Q { func bar() -> Self }

Re: [swift-evolution] Self behaves inconsistently in protocol method signatures

2015-12-28 Thread Matthew Johnson via swift-evolution
> On Dec 28, 2015, at 11:19 AM, Developer wrote: > > My understanding of Self is that it is a special generic parameter resolved > by the type system to the type of the implementing structure. That > resolution must be invariant because the implementing structure

Re: [swift-evolution] Self behaves inconsistently in protocol method signatures

2015-12-28 Thread Joe Groff via swift-evolution
> On Dec 28, 2015, at 8:49 AM, Matthew Johnson via swift-evolution > wrote: > > I have brought up the idea of a non-covarying Self a few times. > > I was surprised to realize that Self is actually non-covarying when used for > parameters in protocol declarations!

Re: [swift-evolution] Self behaves inconsistently in protocol method signatures

2015-12-28 Thread Developer via swift-evolution
My understanding of Self is that it is a special generic parameter resolved by the type system to the type of the implementing structure. That resolution must be invariant because the implementing structure (here, non-final classes) can choose to yank the protocol's invariants out from under

Re: [swift-evolution] Self behaves inconsistently in protocol method signatures

2015-12-28 Thread Matthew Johnson via swift-evolution
> On Dec 28, 2015, at 12:04 PM, Developer wrote: > > That doesn't look like a variance issue to me, that's about the same > "information" invariant I talked about before. The former works because self > resolves to an invariant type, the type of the implementing

Re: [swift-evolution] Self behaves inconsistently in protocol method signatures

2015-12-28 Thread Matthew Johnson via swift-evolution
> On Dec 28, 2015, at 12:43 PM, Joe Groff wrote: > >> >> On Dec 28, 2015, at 10:31 AM, Matthew Johnson > > wrote: >> >>> >>> On Dec 28, 2015, at 12:02 PM, Joe Groff >> >

Re: [swift-evolution] Self behaves inconsistently in protocol method signatures

2015-12-28 Thread Joe Groff via swift-evolution
> On Dec 28, 2015, at 10:31 AM, Matthew Johnson wrote: > >> >> On Dec 28, 2015, at 12:02 PM, Joe Groff > > wrote: >> >>> >>> On Dec 28, 2015, at 8:49 AM, Matthew Johnson via swift-evolution >>>