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

Incorrect WarningCode.CONSTANT_PATTERN_NEVER_MATCHES_VALUE_TYPE for null #52060

Closed
stereotype441 opened this issue Apr 17, 2023 · 1 comment
Closed
Assignees
Labels
analyzer-language-patterns Issues with analyzer's support for the patterns language feature analyzer-warning Issues with the analyzer's Warning codes 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

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.

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

copybara-service bot pushed a commit that referenced this issue Apr 25, 2023
…for Null vs. nullable FunctionType.

Bug: #52060
Change-Id: I5373a9a73396fbf49562131f5f801d1bceeb65f2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298280
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
copybara-service bot pushed a commit that referenced this issue Apr 26, 2023
…E_TYPE for Null vs. nullable FunctionType.

Bug: #52060
Change-Id: I5373a9a73396fbf49562131f5f801d1bceeb65f2
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/298280
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/298380
Reviewed-by: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer-language-patterns Issues with analyzer's support for the patterns language feature analyzer-warning Issues with the analyzer's Warning codes 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

3 participants