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
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.5.0
Xcode Version 10.2.1 (10E1001)
Additional Detail from JIRA
Votes
0
Component/s
Compiler
Labels
Bug
Assignee
None
Priority
Medium
md5: 20f8c9007a8bdceb03d9fbd10a5f2973
duplicates:
SR-7187 False positive warning: cast always fails from '[Any]' to '[String?]'
Issue Description:
The compiler is giving me a warning
Cast from '[String : Any]' to unrelated type '[String : MyProtocol?]' always fails
but this isn't true - at runtime the cast works correctly.
Here's an example showing this:
// Create a protocol, and conform some types to itprotocolMyProtocol { }
extensionInt: MyProtocol { }
extensionString: MyProtocol { }
// Create a dictionary out of those typesletdictionary = [ "a": 1, "b": "2" ] as [String: Any]
// Warning here, but the cast works correctly at runtimeletcastDictionary = dictionaryas? [String: MyProtocol?]
The warning only appears if the dictionary is cast to [String: MyProtocol?]. Casting to [String: MyProtocol] works as expected.
The text was updated successfully, but these errors were encountered:
Environment
Apple Swift version 5.0.1 (swiftlang-1001.0.82.4 clang-1001.0.46.5)
Target: x86_64-apple-darwin18.5.0
Xcode Version 10.2.1 (10E1001)
Additional Detail from JIRA
md5: 20f8c9007a8bdceb03d9fbd10a5f2973
duplicates:
Issue Description:
The compiler is giving me a warning
but this isn't true - at runtime the cast works correctly.
Here's an example showing this:
The warning only appears if the dictionary is cast to [String: MyProtocol?]. Casting to [String: MyProtocol] works as expected.
The text was updated successfully, but these errors were encountered: