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
In your case, you get different behaviour because DictionaryWrapper<String, Any> is conditionally casting to Any, whereas TypedDictionaryWrapper is conditionally casting to Int.
In the case of the former, Any can represent the optional value returned from the dictionary's subscript, therefore no unwrapping occurs. However when casting to Int, the value returned from the subscript is unwrapped in order to see if the underlying value can be represented as an Int.
If you change your TypedDictionaryWrapper implementation to cast to Any, you'll see that the new behaviour is more consistent across generic and non-generic contexts, for example:
Attachment: Download
Environment
Xcode 10 (10A255), macOS 10.13.6, Swift 4.2
Additional Detail from JIRA
md5: a129003507d833383c8d71413feec3bb
duplicates:
Any?
toas? Value
where Value == Any produces unexpected result in Xcode 10Issue Description:
Attempt of optional cast to generic value results in double wrapped optional while same action for explicit type results in simple optional.
Expected result is either optional or compile-time error when trying to return double optional from function returning optional.
See attached project.
The text was updated successfully, but these errors were encountered: