Closed
Description
we do correctly reject the code (new MI()
not being legal in strong mode), but it seems like we're going off the rails a bit here. I would expect the error at the new expressions. Instead we seem to infer non-sensical type arguments for new MI
and new PMI
.
import "package:expect/expect.dart";
// Regression test for recursive inheritance patterns
abstract class Comparable<T> {
int compare(T a);
}
class MI<T extends MI<T>> {}
class PMI<T extends Comparable<T>> extends MI<PMI<T>> {}
void main() {
var a = new MI();
var b = new PMI();
// [error] A value of type 'PMI<Comparable<Comparable<T>>>' cannot be assigned to a variable of type 'MI<MI<MI<T>>>'
a = b;
Expect.isTrue(a is MI);
Expect.isTrue(b is PMI);
Expect.isTrue(b is MI);
Expect.isTrue(b is MI<PMI>);
}