Last active
August 17, 2025 12:04
-
-
Save albertms10/669ab7ca40ebb20ce3484dea50aeb255 to your computer and use it in GitHub Desktop.
Dart lint `omit_local_variable_types` false positive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Quality {} | |
class PerfectQuality extends Quality {} | |
class ImperfectQuality extends Quality {} | |
abstract class NotationSystem<T> implements Parser<T> {} | |
abstract class Parser<T> { | |
bool matches(String source); | |
} | |
class PerfectQualityNotation extends NotationSystem<PerfectQuality> { | |
@override | |
bool matches(String source) => true; | |
} | |
class ImperfectQualityNotation extends NotationSystem<ImperfectQuality> { | |
@override | |
bool matches(String source) => true; | |
} | |
final perfectQualityNotation = PerfectQualityNotation(); | |
final imperfectQualityNotation = ImperfectQualityNotation(); | |
void main({bool flag = true}) { | |
// ignore: omit_local_variable_types Autofixing this lint warning makes `parser.matches` call in L30 crash. | |
final Parser<Quality> parser = flag | |
? perfectQualityNotation | |
: imperfectQualityNotation; | |
parser.matches('foo'); | |
// ^^^^^^^ The method 'matches' isn't defined for the type 'Object'. | |
// Try correcting the name to the name of an existing method, or defining a method named 'matches'. dart(undefined_method) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment