Skip to content

Add type_literal_in_constant_pattern #797

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

Closed
johnpryan opened this issue May 11, 2023 · 4 comments
Closed

Add type_literal_in_constant_pattern #797

johnpryan opened this issue May 11, 2023 · 4 comments

Comments

@johnpryan
Copy link

I recently ran into dart-lang/language#2911 and this seems like a good candidate to add to the recommended set. It's probably something users want more often than not.

@devoncarew devoncarew changed the title Add "type_literal_in_constant_pattern" Add type_literal_in_constant_pattern Jun 1, 2023
@lrhn
Copy link
Member

lrhn commented Sep 19, 2023

I'd really want this warning to be enabled by default in the analyzer, if at all possible.
Even if it's just as a "hint".

Otherwise, I'd put it in core. It's warning about a highly error-prone pattern, and I'd prefer knowing that packages I depend on are aware of the pitfall, and have taken steps to avoid it.

@devoncarew
Copy link
Member

This is approved for the core set.

@Fernandomr88
Copy link

so I have a function that basically is this

get<T>() {
 switch(T) {
  case Person:
   //code
  case Dog:
   //code
  }
}

which is called like get<Person>();

and by using the notation suggested by this rule (Person _), it stopped working.

How am I supposed to change my code to be adequate to this linter rule?

@bwilkerson
Copy link
Member

It sounds like the rule might need to be changed to not produce a diagnostic if the value being switched over is Type.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

6 participants