-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema][CSApply] Be more conservative while emitting always true conversion diagnostic #34980
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@hborla -- Do you think this is the right approach? The question here is how to best deal with the fact that function casts behave differently in the runtime and compiler (the compiler can perform argument/return type conversions that the runtime cannot perform). The previous code emitted some inappropriate diagnostics because of this distinction. |
@tbkka I don't have a deep understanding of the runtime, but from the tests I ran, the runtime couldn't perform any cast other than when the function types were equal, is that really the case? Or there are other situations when the runtime cast is possible? |
The runtime can only cast functions when the arguments and return type are exactly identical. The only permitted difference is in throwing. You can read the details here: |
Awesome! Thanks for the reference :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think makes sense to align solver with runtime but instead of CSApply do more checking simplifyCheckedCastConstraint
instead and record an appropriate warning there.
7e48b94
to
f6dc852
Compare
This is not ready yet, as it still has a lot of things to fix as it requires some changes involving |
f66a544
to
cbabc8e
Compare
@swift-ci Please smoke test |
74140c6
to
9ddaa03
Compare
… and record warning fix
…CheckedCast::attempt
451d295
to
718da8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we are almost there, just a couple more minor comments.
718da8a
to
31ac04f
Compare
@xedin Thanks for the review! I think all points were addressed :) |
@swift-ci Please smoke test |
@swift-ci Please smoke test |
There is a lot of commits, I think will be a good idea just to squash this one. WDYT? |
Sounds good to me! |
Squashed! Thank you @xedin :) |
Be more conservative on always true conversion diagnostics when functions are involved.
Resolves SR-13789.