Skip to content

Conversation

@slavapestov
Copy link
Contributor

  • Explanation: Backport some fixes from master, enabling the fix-it for SE0036 to be used for patterns such as case foo(let x).
  • Scope: Should only impact invalid code that already did not compile, now has a better diagnostic.
  • Reviewed by @jrose-apple
  • Risk: Low.
  • Testing: New test cases added, and observed to pass on master.
  • Radar: rdar://problem/27684266

Suggest a fix-it for unqualified references to all static members
from instance context, not just enum elements.

Also, fix a small problem with the fix-it for replacing protocol
names with 'Self' inside extension bodies -- we didn't handle nested
functions properly.
The problem here is that we would just emit 'invalid pattern'
instead of digging deeper, which meant that the fix-it for
qualified enum element access wasn't getting inserted for
more complex patterns, such as 'case X(let x)'.

Unfortunately, in the matching_patterns.swift test, we emit
too many diagnostics that are not really useful to figuring
out the problem, and the old 'invalid pattern' made more
sense. I'll work on some CSDiag tweaks to address this --
I think it makes more sense to dig there than just emit a
general 'invalid pattern' diagnostic anyway.

Fixes <rdar://problem/27684266>.
@slavapestov
Copy link
Contributor Author

@jrose-apple You already reviewed a larger PR containing these changes on master -- mind doing a quick spot-check on the targeted fix?

@slavapestov
Copy link
Contributor Author

@swift-ci Please smoke test

@slavapestov slavapestov added this to the Swift 3.0 milestone Aug 8, 2016
()
case (_, var e, 3) +++ (1, 2, 3): // expected-error{{invalid pattern}}
case (_, var e, 3) +++ (1, 2, 3):
// expected-error@-1{{binary operator '+++' cannot be applied to operands of type '(_, <<error type>>, Int)' and '(Int, Int, Int)'}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My only concern is leaking <<error type>> into user diagnostics.

@jrose-apple
Copy link
Contributor

Seems all right, save the one comment.

@tkremenek tkremenek merged commit f26e124 into swiftlang:swift-3.0-branch Aug 8, 2016
@slavapestov slavapestov deleted the fix-enum-member-lookup-fixits-3.0 branch August 19, 2016 05:21
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