Skip to content

[analyzer] Wrong warning on extension type in a switch statement #54561

@sgrekhov

Description

@sgrekhov

The code below works well at run time but produces a wrong warning in the analyzer

// SharedOptions=--enable-experiment=inline-class

import "../../Utils/expect.dart";

extension type BoolET(bool _) {}

String test(BoolET o) {
  switch (o) {
    case BoolET _b:  // warning •  The matched value type 'BoolET' can never match the required type 'BoolET'.
                     // Try using a different pattern.
      return "exhaustive";
  }
}

main() {
  Expect.equals("exhaustive", test(BoolET(true)));
}

Tested on Dart SDK version: 3.4.0-edge.bcfab01e878682e268d935c5a866fd6cb854541e (main) (Wed Jan 10 02:10:36 2024 +0000) on "linux_x64"

Metadata

Metadata

Assignees

Labels

P1A high priority bug; for example, a single project is unusable or has many test failuresdevexp-warningIssues with the analyzer's Warning codesfeature-extension-typesImplementation of the extension type featurelegacy-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