-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)
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
Metadata
Metadata
Assignees
Labels
P2A bug or feature request we're likely to work onA bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.Use area-devexp instead.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)