Skip to content
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

"Invert if" should not be offered for if-case #52148

Closed
stereotype441 opened this issue Apr 24, 2023 · 1 comment
Closed

"Invert if" should not be offered for if-case #52148

stereotype441 opened this issue Apr 24, 2023 · 1 comment
Assignees
Labels
analyzer-assist Issues with analysis server assists analyzer-language-patterns Issues with analyzer's support for the patterns language feature area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on

Comments

@stereotype441
Copy link
Member

With the following Dart 3.0 code:

f(num n) {
  if (n case int()) {
    print("it's an int");
  } else {
    print("it's not an int");
  }
}

Place the cursor on the if token and request quick assists.

Expected result: the quick assist "invert if" should not be offered.

Observed result: the quick assist "invert if" is offered, and its behaviour doesn't preserve semantics. (It exchanges the if and else blocks, but doesn't change the if statement in any other way.)

Reproduced in 60fec9c.

@stereotype441 stereotype441 added area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. analyzer-assist Issues with analysis server assists analyzer-language-patterns Issues with analyzer's support for the patterns language feature labels Apr 24, 2023
@scheglov scheglov added the P2 A bug or feature request we're likely to work on label Apr 24, 2023
@scheglov scheglov self-assigned this Apr 24, 2023
@scheglov
Copy link
Contributor

copybara-service bot pushed a commit that referenced this issue Apr 24, 2023
Disable a few assists that require 'patterns', when it is not enabled.

Bug: #52148
Change-Id: I3c3816f4a944c59698543e37f15e024249545952
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/297880
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-assist Issues with analysis server assists analyzer-language-patterns Issues with analyzer's support for the patterns language feature area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on
Projects
None yet
Development

No branches or pull requests

2 participants