solid-software / solid_lints

🟧 Lints for Dart and Flutter based on software industry standards and best practices.
Other
36 stars 18 forks source link

unexpected avoid_unnecessary_type_assertions #127

Closed danylo-safonov-solid closed 6 months ago

danylo-safonov-solid commented 7 months ago

https://github.com/danylo-safonov-solid/avoid_unnecessary_type_assertions_bug image

// ignore_for_file: public_member_api_docs, prefer_match_file_name, lines_longer_than_80_chars

class A {

}

class B extends A {

}

class C extends A {

}

void noLint() {
  final A a = B();
  // Unnecessary usage of the 'is' operator.dart(avoid_unnecessary_type_assertions)
  if (a is! C) return;
}

void lint() {
  final A a = B();
  if (a is C) return;
}