Closed
Description
This code passes strong mode, but the second call to eatFood
will fail at runtime since there is no actual eatFood
method on MockCat
. It's not clear that we want to just disallow this pattern entirely, but unconditionally disabling the unimplemented member warnings without doing something to make it sound is clearly the wrong thing.
class Cat {
bool eatFood(String food) => true;
}
class MockCat implements Cat {
dynamic noSuchMethod(Invocation invocation) {
return 3;
}
}
void main () {
print((new MockCat() as dynamic).eatFood(""));
print(new MockCat().eatFood(""));
}