Skip to content

Incorrect WarningCode.CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE for null #52060

@stereotype441

Description

@stereotype441

This code:

class C {
  void Function()? callback;
}

f(Object o) {
  switch (o) {
    case C(callback: null): // (1)
  }
}

Produces the diagnostic WarningCode.CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE at (1).

There should not be any warning; callback is nullable, so null is a possible match.

Reproduced with fa3a72f.

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-warningIssues with the analyzer's Warning codeslegacy-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