-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Sema] Penalize conversions to Any. #7233
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
[Sema] Penalize conversions to Any. #7233
Conversation
…ersion. This change is needed by a separate change I have that penalizes conversions to Any. That change exposed a problem where we ended up doing a direct lvalue-to-Any conversion without first loading as part of an lvalue-to-rvalue conversion. We should really only be doing most of these other conversions/fixes on rvalues. Unfortunately I don't know of a way to hit this without the other change, and thus don't have a test case. As a side note, this also helps some (perhaps most, but definitely not all) of the exponential type inference cases involving arrays and dictionaries. Unfortunately again, we don't currently have a testing mechanism in place to ensure we don't regress those cases, and I don't want to add a test that will completely hang every bot if it does regress, so...*sad face*...no test case for that either. (cherry picked from commit 13a6574)
We previously penalized bindings to Any, and that resulted in inappropriately rejecting solutions where we bind a decl that is explicitly typed Any. That penalty was removed in 170dc8a, but that has led to a variety of source compatibility issues. So now, we'll reintroduce a penalty for Any-typed things, but instead of penalizing bindings (which happen both because of explicitly-typed values in the source, and implicitly due to attempting various types for a particular type variable), penalize casts, which are always present in some form in the source. Thanks go to John for the suggestion. Fixes SR-3817 (aka rdar://problem/30311052) SR-3786 (aka rdar://problem/30268529) rdar://problem/29907555 (cherry picked from commit 00cc260)
@swift-ci Please test |
Build failed |
The failure is totally unrelated to my changes. |
@swift-ci Please test OS X platform |
Build failed |
@swift-ci Please test OS X platform One more try! |
@swift-ci Please test OS X platform |
Build failed |
@swift-ci Please clean test OS X platform |
[Sema] Penalize conversions to Any.
We previously penalized bindings to Any, and that resulted in
inappropriately rejecting solutions where we bind a decl that is
explicitly typed Any. That penalty was removed in
170dc8a, but that has led to a
variety of source compatibility issues.
So now, we'll reintroduce a penalty for Any-typed things, but instead
of penalizing bindings (which happen both because of explicitly-typed
values in the source, and implicitly due to attempting various types
for a particular type variable), penalize casts, which are always
present in some form in the source.
Thanks go to John for the suggestion.
Fixes