sdk
sdk copied to clipboard
Detect dead code in cases where an is check is redundant
All blocks after the first if, are dead code.
bool _isStatic(Element element) {
if (element is ClassMemberElement) {
return element.isStatic;
} else if (element is ClassMemberElement) {
return element.isStatic;
} else if (element is ClassMemberElement) {
return element.isStatic;
} else if (element is ClassMemberElement) {
return element.isStatic;
}
I think the invariant_booleans lint rule should cover this. But it doesn't for now.
I disagree. The invariant_booleans diagnostic is a lint because it has false positives, but it doesn't appear to me that this can. This seems much more akin to the kind of dead code analysis that we do for catch clauses:
class SuperException {}
class SubException extends SuperException {}
void f() {
try {
...
} on SuperException {
...
} on SubException {
// Caught as dead code because the clause above would catch anything intended to be caught here.
...
}
}
Ah, good point!