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
The stdlib has a trick that it uses to interact with Cocoa that we've dubbed "shadow protocols". The basic idea is this:
@objcprotocolShadow {
@objc(doThing:) funcdoTheThing() -> Int
}
@_effects(releasenone)
privatefuncdoThingImpl(_x: Shadow) -> Int {
returnx.doTheThing()
}
@_effects(releasenone)
funccocoaDoThing(_x: AnyObject/* but we know it's actually a particular ObjC object type */) -> Int {
returndoThingImpl(_unsafeReferenceCast(x, to: Shadow.self))
}
This is quite a bit of fiddly machinery for what's ultimately a simple task: call objc_msgSend with a particular selector and calling convention. It gets even more hairy when we want to call objc_msgSend_super instead.
Could we have a direct way to express this?
The text was updated successfully, but these errors were encountered:
My claim here, which may be incorrect, is that the step that's losing the release none is the bitcast. If we had a way like this to just say "no really just send a message to this object, I know you don't think it will work" then there'd be no reason to bitcast.
Additional Detail from JIRA
md5: cb83d905c400d8322d6435593b784d15
relates to:
Issue Description:
Note: this would obviate the need for https://bugs.swift.org/browse/SR-11249 entirely
The stdlib has a trick that it uses to interact with Cocoa that we've dubbed "shadow protocols". The basic idea is this:
This is quite a bit of fiddly machinery for what's ultimately a simple task: call objc_msgSend with a particular selector and calling convention. It gets even more hairy when we want to call objc_msgSend_super instead.
Could we have a direct way to express this?
The text was updated successfully, but these errors were encountered: