> On Sep 8, 2016, at 6:28 AM, Karl Wagner via swift-users
> wrote:
>
> It is in some sense a language limitation that we cant express what you're
> talking about. If we weren't using mailing lists it would be easier to search
> for "protocol self-conformance" on
What I'm trying to say is that P is a protocol and not a class, so it does not
conform to AnyObject. P does not conform to P.
It is in some sense a language limitation that we cant express what you're
talking about. If we weren't using mailing lists it would be easier to search
@Karl,
You say "In the second example, you’re creating WeakReference. P does
not conform to P or to AnyObject.", but P does conform to AnyObject.
I suspect it is a compiler limitation/ bug.
-- Howard.
On Thursday, 1 September 2016, Karl wrote:
>
> On 1 Sep 2016, at
Playing around I found that if you make the protocol @objc instead of
AnyObject then it works :). EG:
struct WeakReference {
weak var value: T?
}
@objc protocol P { // Note @objc, class or AnyObject does not work
var i: Int { get }
}
class CP: P {
var i: Int = 0
}
let weakPs:
Hi,
I am wanting to use weak references in generic data structures; in the
example below Array, but in general any generic type. I can almost get it
to work :(
My experiments started off well; the following works:
// Array of weak references OK
struct WeakReference {
weak var value: T?
}