Skip to content

Don't use construction to convert literals in rawValue fix-it. #4943

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

Conversation

jrose-apple
Copy link
Contributor

  • Explanation: We have a fix-it for when the user tries to pass a bare value to a type that's RawRepresentable with that type, as long as it's a type that's expressible-by-literal. The fix-it is smart enough to insert an extra converting construction if the raw value type doesn't match exactly, but it's not smart enough to omit that if the bare value is itself a literal (and would be inferred to the correct type). Fix that by just checking for a literal expression before inserting the conversion.
  • Scope: Affects failure diagnosis involving RawRepresentable types.
  • Issue: rdar://problem/26681232
  • Reviewed by: @nkcsgexi
  • Risk: Very low.
  • Testing: Added a compiler regression test, verified that the originally reported case now gets useful fix-its.

…lang#4934)

Input:  panel.styleMask = 8345
Old output:  panel.styleMask = NSWindowStyleMask(rawValue: UInt(8345))
New output:  panel.styleMask = NSWindowStyleMask(rawValue: 8345)

rdar://problem/26681232
(cherry picked from commit b9e1d4c)
@jrose-apple
Copy link
Contributor Author

@swift-ci Please test

@slavapestov
Copy link
Contributor

Thanks for taking this one.

@tkremenek tkremenek merged commit 822e3dd into swiftlang:swift-3.0-branch Sep 23, 2016
@jrose-apple jrose-apple deleted the swift-3-rawValue-literals branch September 23, 2016 15:40
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