Re: [swift-users] Using 'SomeProtocol' as a concrete type conforming to protocol 'SomeProtocol' is not supported

2016-12-29 Thread Rien via swift-users
As to the why question: (just guessing here) By the time the compiler want to know what type will be in the array, it cannot do so. The enum is a generic and thus without full type information (it only has partial type information). Regards, Rien Site: http://balancingrock.nl Blog:

Re: [swift-users] Using 'SomeProtocol' as a concrete type conforming to protocol 'SomeProtocol' is not supported

2016-12-28 Thread Ray Fix via swift-users
Using Optional, your enum type goes away. (I think it is a great solution unless you need something more than .element and .none in real life.) Great to get all that optional machinery for missing values for free! Then you can constrain elements simply from the Element protocol as in as in:

Re: [swift-users] Using 'SomeProtocol' as a concrete type conforming to protocol 'SomeProtocol' is not supported

2016-12-28 Thread Brandon Knope via swift-users
Aren’t I losing the ability to enforce what is going into this enum’s associated value then? Brandon > On Dec 28, 2016, at 7:05 PM, Nevin Brackett-Rozinsky > wrote: > > It will work if you change the enum declaration to: > > enum ElementNode > > In other

Re: [swift-users] Using 'SomeProtocol' as a concrete type conforming to protocol 'SomeProtocol' is not supported

2016-12-28 Thread Nevin Brackett-Rozinsky via swift-users
It will work if you change the enum declaration to: enum ElementNode In other words, let the enum hold arbitrary unconstrained associated types, and then make your APIs utilize instances of the enum with the associated type constrained to a protocol. The specific example you provide is

[swift-users] Using 'SomeProtocol' as a concrete type conforming to protocol 'SomeProtocol' is not supported

2016-12-28 Thread Brandon Knope via swift-users
I don’t understand why this is a problem protocol Element { } enum ElementNode { case element(T) case empty } var childElements = [ElementNode]() I need to represent an array of my nodes that could be multiple kinds of elements Is there a workaround?