Fix Bad diagnostic for `any P!`
Hello Team, In This PR tries to solve an issue where we get two errors emitted for:
protocol P {}
// error: using '!' is not allowed here; perhaps '?' was intended? [implicitly_unwrapped_optional_in_illegal_position]
// error: optional 'any' type must be written '(any P2)?' [incorrect_optional_any]
let _: any P!
the first error here isn't useful, so we should only emit a single error.
i fixed it by exclude ExistentialConstraint from resolveImplicitlyUnwrappedOptionalType thus, we don't get the un-needed diagnostic emitted.
i tried to work on a fix without touching resolveImplicitlyUnwrappedOptionalType and instead do something in:
TypeResolver::resolveExistentialType but it didn't work, as at that point we already get a diagnostics emitted from resolveImplicitlyUnwrappedOptionalType
after applying my fix we get only one error emitted
Please let me know what do you think about this proposed solution!
Resolves #72662
Hi @AnthonyLatsis would really appreciate your review & feedback here
Thanks @AnthonyLatsis ! you are correct my fix prefers replacing force unwrapping with an optional, i will work on adjusting my solution to prefer force unwrapping
btw, current fix emits the following for the case you mentioined, which - i think- isn't illegal ? it's still preferring optionals. (which what should be adjusted)
error: optional 'any' type must be written '(any P)?'
let _: (Int, any P!)
^~~~~~
(any P)?
in my next iteration i will test both cases
@swift-ci please smoke test Linux
hi @AnthonyLatsis, i know that all the team is busy with swift6 release would appreciate your feedback about the new implementation 🙏🏻
can you take a look here @xedin ;)
Sure, this is next in my queue!
Thanks @AnthonyLatsis for the detailed review, i will work on the suggestions and re-assign you for the review
HI @AnthonyLatsis can i get your feedback here 🙏🏻
@xedin would also appreciate your eye here ;)