Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-06 Thread Christopher Kornher via swift-evolution
This issue bites me frequently and is a barrier to clean "protocol-based” programming. This is extremely counter-intuitive to me, at least. Not having a good workaround for this really makes the language seem incomplete. Recently I had the need to use instances of a protocol as keys in a diction

Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-06 Thread Charles Srstka via swift-evolution
The need to use === is at the root of my problem as well. Charles > On Dec 6, 2016, at 1:30 PM, Андрей Володин via swift-evolution > wrote: > > Been struggling with this kind of problem. My case: I have an array of class > protocol and can’t use my extension that removes AnyObject from array

Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-06 Thread Андрей Володин via swift-evolution
Been struggling with this kind of problem. My case: I have an array of class protocol and can’t use my extension that removes AnyObject from array by comparing pointers via ===. ___ swift-evolution mailing list swift-evolution@swift.org https://lists.s

Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-05 Thread Joe Groff via swift-evolution
> On Dec 5, 2016, at 10:50 AM, Charles Srstka wrote: > >> On Dec 5, 2016, at 11:39 AM, Joe Groff > > wrote: >> >>> On Dec 4, 2016, at 6:46 PM, Charles Srstka via swift-evolution >>> mailto:swift-evolution@swift.org>> wrote: >>> >>> The following currently does not wor

Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-05 Thread Charles Srstka via swift-evolution
> On Dec 5, 2016, at 11:39 AM, Joe Groff wrote: > >> On Dec 4, 2016, at 6:46 PM, Charles Srstka via swift-evolution >> wrote: >> >> The following currently does not work: >> >> protocol P: class {} >> class C: P {} >> >> func foo(t: T) where T: AnyObject { >> print("foo") >> } >> >> le

Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-05 Thread Joe Groff via swift-evolution
> On Dec 4, 2016, at 6:46 PM, Charles Srstka via swift-evolution > wrote: > > The following currently does not work: > > protocol P: class {} > class C: P {} > > func foo(t: T) where T: AnyObject { > print("foo") > } > > let p: P = C() > > foo(t: p) // error: cannot invoke 'foo' with

Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-05 Thread Charles Srstka via swift-evolution
> On Dec 4, 2016, at 11:49 PM, Derrick Ho wrote: > > Does the following expression evaluate to true? > > p is AnyObject > > If it does then you may have found a bug. Not only does it evaluate to true, the compiler warns me that "'is' test is always true”. Charles ___

Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-05 Thread Anders Ha via swift-evolution
This is not a bug. Existentials of a protocol do not conform to the protocol. But I have no idea why the protocol conformance has not been implemented for at least protocols without `Self` or associated type requirements though. Regards, Anders > On 5 Dec 2016, at 3:46 AM, Charles Srstka via sw

Re: [swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-04 Thread Derrick Ho via swift-evolution
Does the following expression evaluate to true? p is AnyObject If it does then you may have found a bug. On Sun, Dec 4, 2016 at 9:46 PM Charles Srstka via swift-evolution < swift-evolution@swift.org> wrote: > The following currently does not work: > > protocol P: class {} > class C: P {} > > fun

[swift-evolution] Passing class protocols to functions accepting AnyObject

2016-12-04 Thread Charles Srstka via swift-evolution
The following currently does not work: protocol P: class {} class C: P {} func foo(t: T) where T: AnyObject { print("foo") } let p: P = C() foo(t: p) // error: cannot invoke 'foo' with an argument list of type '(t: P)' It seems to me that this ought to have been allowed, since P is dec