Skip to content

[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

Merged
merged 2 commits into from
Feb 5, 2017
Merged

[Sema] Penalize conversions to Any. #7233

merged 2 commits into from
Feb 5, 2017

Conversation

rudkx
Copy link
Contributor

@rudkx rudkx commented Feb 3, 2017

[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

  • SR-3817 (aka rdar://problem/30311052)
  • SR-3786 (aka rdar://problem/30268529)
  • rdar://problem/29907555

rudkx added 2 commits February 3, 2017 11:03
…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)
@rudkx rudkx added this to the Swift 3.1 milestone Feb 3, 2017
@rudkx
Copy link
Contributor Author

rudkx commented Feb 3, 2017

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - bb0b264
Test requested by - @rudkx

@rudkx
Copy link
Contributor Author

rudkx commented Feb 3, 2017

The failure is totally unrelated to my changes.

@rudkx
Copy link
Contributor Author

rudkx commented Feb 3, 2017

@swift-ci Please test OS X platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - bb0b264
Test requested by - @rudkx

@rudkx
Copy link
Contributor Author

rudkx commented Feb 3, 2017

@swift-ci Please test OS X platform

One more try!

@rudkx
Copy link
Contributor Author

rudkx commented Feb 3, 2017

@swift-ci Please test OS X platform

@swift-ci
Copy link
Contributor

swift-ci commented Feb 3, 2017

Build failed
Jenkins build - Swift Test OS X Platform
Git Commit - bb0b264
Test requested by - @rudkx

@rudkx
Copy link
Contributor Author

rudkx commented Feb 3, 2017

@swift-ci Please clean test OS X platform

@tkremenek tkremenek merged commit 103882f into swiftlang:swift-3.1-branch Feb 5, 2017
@rudkx rudkx deleted the fix-rdar30311052-3.1 branch February 5, 2017 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants