Skip to content

[4.2] Prefer RawRepresentable fix-its that don't require an extra conversion #17724

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 1 commit into from
Jul 4, 2018

Conversation

jrose-apple
Copy link
Contributor

@jrose-apple jrose-apple commented Jul 3, 2018

  • Explanation: The fix-it for automatically inserting .rawValue when necessary was producing an unnecessary and possibly dangerous conversion when more than one numeric type was accepted by a method. In addition, the fix-it itself was syntactically invalid when the expression was a single, unlabeled call argument. This change fixes both of those issues by stripping parentheses and preferring an overload that exactly matches a raw or wrapping type.

  • Scope: Affects error diagnostics only, and even then only cases where we would have already decided that this was the right message to emit. This does come up in migration due to new NS_TYPED_ENUMs.

  • Issue: SR-8150 / rdar://problem/41725207

  • Risk: Low. It's mostly the same logic as before, just without an early exit.

  • Testing: Added compiler regression tests.

  • Reviewed by: @DougGregor

Prefer RawRepresentable fix-its that don't require an extra conversion

https://bugs.swift.org/browse/SR-8150
(cherry picked from commit 9116f95)
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@jrose-apple
Copy link
Contributor Author

@swift-ci Please nominate

@jrose-apple jrose-apple merged commit a3b5684 into swiftlang:swift-4.2-branch Jul 4, 2018
@jrose-apple jrose-apple deleted the 4.2-raw-deal branch July 4, 2018 02:55
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.

1 participant