Closed
Description
This example:
class A { const A(); }
class B implements A { const B(); }
class M<T extends A> {
final T a;
const M(dynamic t): a = t;
}
main() {
print(const M<B>(const B()));
}
Incorrectly fails with:
Error: `const B()` of type 'B' is not a subtype of M.T.
print(const M<B>(const B()));
^
This is the same reason why this code fails too:
class M<T extends num> {
final T a;
const M(T t): a = -t * 0;
}
main() {
print(const M(2.1));
}
because t*0
is a closed operation (returns int or double depending on the input type).
The latter is found in core types like Rectangle
in dart:math
.