Skip to content

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

@stereotype441

Description

@stereotype441

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.

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work ondart-model-language-patternsIssues with analyzer's support for the patterns language featuredevexp-assistIssues with analysis server assistslegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions