Skip to content

unnecessary_null_check_pattern false negative #60975

Open
@FMorschel

Description

@FMorschel

Repro:

// ignore_for_file: unused_local_variable
class Foo {
  num? foo;
  num bar = 0;
}

void foo(Foo f) {
  if (f case Foo(:num foo?, :var bar?,)) {}
}

The second ? inside the pattern match triggers unnecessary_null_check_pattern but not the first. I'd say that since we are testing for the explicit num (non-nullable type), it should trigger, too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3A lower priority bug or feature requestarea-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-linterIssues with the analyzer's support for the linter package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions