Skip to content

Add type_literal_in_constant_pattern #797

Closed
@johnpryan

Description

@johnpryan

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.

Activity

changed the title [-]Add "type_literal_in_constant_pattern"[/-] [+]Add `type_literal_in_constant_pattern`[/+] on Jun 1, 2023
lrhn

lrhn commented on Sep 19, 2023

@lrhn
Member

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

devoncarew commented on Sep 19, 2023

@devoncarew
Member

This is approved for the core set.

Fernandomr88

Fernandomr88 commented on Oct 23, 2023

@Fernandomr88

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

bwilkerson commented on Oct 23, 2023

@bwilkerson
Member

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

transferred this issue fromdart-archive/lintson Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @johnpryan@devoncarew@lrhn@bwilkerson@Fernandomr88

        Issue actions

          Add `type_literal_in_constant_pattern` · Issue #797 · dart-lang/core