[swift-dev] Emitting redundant protocol conformances to support type lookup
owenzx at gmail.com
Fri Jan 8 04:09:05 CST 2016
According to Swift docs on AnyObject,
The protocol to which all classes implicitly conform.
So it is not
an explicit conformance.
On Fri, Jan 8, 2016 at 4:50 PM, Luke Howard via swift-dev <
swift-dev at swift.org> wrote:
> In the fix for [SR-381] (links at end) we implement an API for looking up
> classes by name by searching the protocol conformance table. The initial
> consumer of this is NSClassFromString() as used by NSKeyedUnarchiver in
> The limitation of this approach is that only classes that explicitly
> conform to protocols can be resolved. We’ll work around this in Foundation
> by having subclasses that otherwise inherit their protocol conformance
> explicitly conform to a dummy protocol. However, this behaviour is
> confusing and would be nice to fix.
> One approach I’ve been playing with is for classes always to have an
> explicit conformance to AnyObject (at least, if they don’t explicitly
> conform to anything else). (I have a bit of a hacky patch to implement this
> but it’s failing at link time as there’s no symbol for “_TMps9AnyObject”.)
> Before I proceed further down this path – is this an approach worth
> pursuing or would it be better not to abuse the conformance table for name
> lookups long term?
> — Luke
> swift-dev mailing list
> swift-dev at swift.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-dev