[SR-14112] errors around casting optional CFString to String are confusing/cyclical #56498
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
diagnostics QoI
Bug: Diagnostics Quality of Implementation
type checker
Area → compiler: Semantic analysis
Environment
MacOS 11.1 (20C69) , XCode 12.3 (12C33), building for MacOS 11 and up
Additional Detail from JIRA
md5: 89faac67204a3b8841879f98f4cb36f0
Issue Description:
I am attempting to use CTFont code, and wrote this code:
which spawned this error: "CFString is not impicitly convertable to String, did you mean to use
as
to explicitly convert"Following this advice gives us this code:
which then prompted the error "CFString? is not convertable to String, did you mean to use
as!
to force downcast?" which seems incorrect, since the actual issue is that we need to cast to `String?`, (adding the optional).additionally, if you go with that suggestion again:
you get the warning "Forced cast from `CFString?` to `String` only unwraps and bridges, did you mean to use
!
withas
?"which is particularly frustrating as it seems to be suggesting that we return to the code that was originally written!
the successfully compiling code here is:
I would expect that at some point in this cycle the suggestion would be to cast to an optional String, rather than adjusting the type of casting that is happening.
The text was updated successfully, but these errors were encountered: