Closed
Description
Look at the following example of the code:
class A {}
class C extends A {}
void main() {
C c = new A();
}
In a strong mode analyzer produces an error "[error] Type check failed: new A() (A) is not of type C" and this is an expected result. You can't assign A to type C. But let's rewrite the example above in the following way:
class A {}
class C extends A {
A get a => new A();
}
void main() {
C c = new C().a;
}
Instance of A assigned to variable of type C and analyzer (1.19.1 and 1.20.0-dev.10.2) finds no issues here. There should be an error as well