> On May 12, 2016, at 18:34, Andrew Trick <atr...@apple.com> wrote:
> 
>> - On the flip side, I think we do need to preserve the ability to 
>> reference-cast in order to send Objective-C messages, at least for now. I 
>> don’t know how I want to expose that to users, though. (In general it’s 
>> probably worth seeing how unsafeBitCast is used in the wild and what we’d 
>> recommend instead.)
> 
> Does ``X as Y`` fail for some reason? We have unchecked versions of ``X as 
> Y`` for performance reasons: ``unsafeDowncast`` and ``_unsafeReferenceCast``.


The particular case I’m thinking about is where we reinterpret an AnyObject as 
an @objc protocol because we don’t know the dynamic type we would need to add a 
method to. This doesn’t happen much, and maybe we just say sending arbitrary 
messages requires an ObjC-side workaround. Or we commit to 
‘_unsafeReferenceCast’ and de-underscore it.

(_unsafeReferenceCast is probably a better choice for StdlibUnittest, which is 
where I used this.)

Jordan
_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

Reply via email to