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
NSAttributedString(one of many examples being open func addAttribute(_ name: NSAttributedString.Key, value: Any, range: NSRange) )
Using these APIs on Android (and presumably on other non-objc-supporting platforms) results in a crash on the current master when providing values to the Any parameters that are notNSObject s. This seems to be due to Foundation/Bridging.swift:199 which performs a force-cast: return (value as AnyObject) as! NSObject
This seems to be an unintended bug to me (if these APIs should only accept AnyObject / NSObject, let's say so in the API contract, but my gut feeling is that that shouldn't be necessary). It's possible that value as AnyObject casting has been broken by recent changes in Swift itself. It would be good to get some insight as to what's changed here and what we can do to fix it.
The text was updated successfully, but these errors were encountered:
@millenomi I'm tagging you because you made the last functional changes in Bridging.swift (even though I don't think those changes are causing the current issue)
ianpartridge (JIRA User) I'm tagging you because I understand you may have an idea of when this issue started happening and/or whether it's expected behaviour
It makes sense as a bug to fix — on Darwin, all Swift objects can respond to NSObject methods when passed to an ObjC method, but not all of them do or are in s-c-f. You can work around this for now by making objects NSObjects, but we should honor the contract and allow any value, or box those objects in __SwiftValues (which are NSObjects).
Environment
Android: armv7a, arm64-v8a, x86_64 confirmed
Linux: Probably?
Darwin: Probably not- assuming this only happens in the non-objc paths
Additional Detail from JIRA
md5: 6d906e4ba53d6d7fe5fe5925a0bd30ae
Issue Description:
Many Foundation APIs take
Any
as an input, two examples of which are:Notification (
public init(name: Name, object: Any? = nil, userInfo: [AnyHashable : Any]? = nil)
)NSAttributedString(one of many examples being
open func addAttribute(_ name: NSAttributedString.Key, value: Any, range: NSRange
) )Using these APIs on Android (and presumably on other non-objc-supporting platforms) results in a crash on the current master when providing values to the
Any
parameters that are notNSObject
s. This seems to be due toFoundation/Bridging.swift:199
which performs a force-cast:return (value as AnyObject) as! NSObject
This seems to be an unintended bug to me (if these APIs should only accept
AnyObject
/NSObject
, let's say so in the API contract, but my gut feeling is that that shouldn't be necessary). It's possible thatvalue as AnyObject
casting has been broken by recent changes in Swift itself. It would be good to get some insight as to what's changed here and what we can do to fix it.The text was updated successfully, but these errors were encountered: