File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -858,4 +858,25 @@ CastsTests.test("Casting Objects retained from KeyPaths to Protocols is not work
858
858
expectNotNil ( value as? SuperProtocol )
859
859
}
860
860
861
+ // Known to still be broken, but we can document the issue here
862
+ public protocol SomeProtocol { }
863
+ extension NSString : SomeProtocol { }
864
+ CastsTests . test ( " NSDictionary -> Dictionary casting [SR-12025] " ) {
865
+ // Create NSDictionary with one entry
866
+ var a = NSMutableDictionary ( )
867
+ a [ NSString ( " key " ) ] = NSString ( " value " )
868
+
869
+ let v = NSString ( " value " )
870
+ let v2 = v as? SomeProtocol
871
+ expectNotNil ( v2)
872
+
873
+ // Test casting of the dictionary
874
+ let b = a as? [ String : SomeProtocol ]
875
+ expectFailure { expectNotNil ( b) } // Expect non-nil, but see nil
876
+ let c = a as? [ String : Any ]
877
+ expectNotNil ( c) // Non-nil (as expected)
878
+ let d = c as? [ String : SomeProtocol ]
879
+ expectNotNil ( d) // Non-nil (as expected)
880
+ }
881
+
861
882
runAllTests ( )
You can’t perform that action at this time.
0 commit comments