Skip to content

[6.0][CodeCompletion] Fix completion for 'catch' pattern bound values #73189

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Apr 22, 2024

Cherry-pick #73123 into release/6.0

  • Explanation: Previously code completion for 'catch' pattern bound values didn't work correctly because code completion type checker fails to type check the value decl in the pattern. That was because the body of the do statement is not type checked, so the thrown error is not determined. To resolve this, always type check the body when type checking catch patterns. Also, pretend do {} body throws any Error even without any throwing expressions in it.
  • Scope: 'catch' patterns type checking
  • Risk: Low. This makes the catch pattern type checking a bit lenient, but typed throw is a new feature, and this change effectively restores 5.10 behavior.
  • Test: Updated regression test cases
  • Issues: rdar://126699879
  • Reviewer: Alex Hoppen (@ahoppen)

Previously code completion for 'catch' pattern bound values didn't work
correctly because code completion type checker fails to type check the
value decl in the pattern.
That was because the body of the 'do' statement is not type checked, so
the thrown error is not determined, then falled backed to the default
'Never', which doesn't matches any patterns.
To resolve this, always type check the body when typechecking 'catch'
patterns. Also, pretends 'do {}' throws 'any Error' even without
any throwing expressions in the body.

rdar://126699879
(cherry picked from commit 0e12254)
@rintaro rintaro requested a review from a team as a code owner April 22, 2024 22:51
@rintaro
Copy link
Member Author

rintaro commented Apr 22, 2024

@swift-ci Please test

@rintaro rintaro merged commit 60b453c into swiftlang:release/6.0 Apr 24, 2024
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.

2 participants