This repository was archived by the owner on Feb 22, 2018. It is now read-only.
This repository was archived by the owner on Feb 22, 2018. It is now read-only.
task model: override inference not working for final fields when subtype narrows the type #348
Closed
Description
testChecker(
'infer from RHS only if it wont conflict with overridden fields 2',
{
'/main.dart': '''
class A {
final x;
}
class B extends A {
final x = 2;
}
foo() {
String y = /*severe:StaticTypeError*/new B().x;
int z = new B().x;
}
'''
},
inferFromOverrides: true);
Naturally non-final fields need to be invariant. But subtypes should be allowed to narrow final
fields, right? The test above expects B.x to be inferred as int
because that doesn't violate the contract of A.x