You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SR-11268 Builtins for objc_msgSend/objc_msgSend_super
Issue Description:
The standard library has a trick it uses where it declares an @objc protocol with some selectors, and then unsafeBitCasts things to it to get swiftc to generate objc_msgSends without having to link the libraries that declare those methods.
This works great up until you attempt to get ARC to stop defensively retaining the receiver:
* Putting @_effects(releasenone) on the function that does the bit cast doesn't work because the bit cast loses the object identity
* Putting @_effects(releasenone) on the protocol doesn't work, presumably because protocols don't support that
* Putting @_effects(releasenone) on a second "thunk" function that takes the protocol type does work, and is what I'm doing in #26422 but is pretty clunky
Could we have a nicer way to do this? A few possible ideas, which I have no preference between:
* Could make @_effects work on protocol declarations
* Could teach ARC that unsafeBitCasting from a reference type to an @objc protocol type maintains object identity and maintains @_effects relevant to that identity
* Could provide a builtin or something for calling objc methods that the compiler doesn't statically know about, instead of unsafeBitCasting to a fake protocol
The text was updated successfully, but these errors were encountered:
Additional Detail from JIRA
md5: 7a6b9d196fddd63e3fcebbb14fcad133
relates to:
Issue Description:
The standard library has a trick it uses where it declares an @objc protocol with some selectors, and then unsafeBitCasts things to it to get swiftc to generate objc_msgSends without having to link the libraries that declare those methods.
This works great up until you attempt to get ARC to stop defensively retaining the receiver:
* Putting @_effects(releasenone) on the function that does the bit cast doesn't work because the bit cast loses the object identity
* Putting @_effects(releasenone) on the protocol doesn't work, presumably because protocols don't support that
* Putting @_effects(releasenone) on a second "thunk" function that takes the protocol type does work, and is what I'm doing in #26422 but is pretty clunky
Could we have a nicer way to do this? A few possible ideas, which I have no preference between:
* Could make @_effects work on protocol declarations
* Could teach ARC that unsafeBitCasting from a reference type to an @objc protocol type maintains object identity and maintains @_effects relevant to that identity
* Could provide a builtin or something for calling objc methods that the compiler doesn't statically know about, instead of unsafeBitCasting to a fake protocol
The text was updated successfully, but these errors were encountered: