Misleading error message when assigning a value from [String : AnyObject]

Originator:philippe.latulippe
Number:rdar://23670252 Date Originated:26/11/2015
Status:Closed Resolved:Xcode 7.3 beta
Product:Developer Tools Product Version:Version 7.1.1 (7B1005)
Classification: Reproducible:
 
Retrieve an element from a dictionary where the values are of type AnyObject, and assign it to a variable of a more specific type. The compiler will complain that the type of the subscript is incorrect, rather than stating that AnyObject is not convertible to the more specific type. It will say:

Cannot subscript a value of type '[String : AnyObject]' with an index of type 'String'

But it should say:

'AnyObject' is not convertible to 'String'; did you mean to use 'as!' to force downcast?

See the attached code.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!