Open
Description
Repro:
class A {
A(this.value);
A.named({this.value});
final int? value;
}
// Reason for the constructors to all have the same parameters would be consistency and tear-off possibility
class B extends A {
B(super.value);
B.named({super.value}) : super.named();
}
// Here everything is fine
class C extends A {
C(void value) : super(0);
C.named({void value}) : super.named();
}
class D extends C {
D(super.value);
D.named({super.value}) : super.named();
}
void main() {
D(0);
D.named(value: 0);
}
Error:
lib/a.dart:19:18: Error: This expression has type 'void' and can't be used.
a.dart:19
D.named({super.value}) : super.named();
^
Old
The problem here is that there is no analyzer warning at D.named({super.value})
, and the error happens when running. This can be fixed if we simply replace super.value
with void value
, but that is harder IMO.
The problem here (considering lrhn's first comment on this issue) is that the CFE is wrong. We should be able to compile the code. The analyzer shows no diagnostics and this is WAI.