You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
abstract class A {
int prop;
}
class B {
B(this.obj);
Object obj;
void meth1(Object obj) {
if (obj is A) {
print(obj.prop); // Ok.
}
}
void meth2() {
if (obj is A) {
print(obj.prop); // Error: The getter 'prop' isn't defined for the type 'Object'.
}
}
}
The text was updated successfully, but these errors were encountered:
Instance variables cannot soundly be promoted (so obj doesn't get the type A in the if), because they can be overridden by a getter that could return a different object each time it is invoked. It is being debated whether we should allow an unsound mechanism (so each access would be checked dynamically), or maybe support easy introduction of a fresh variable whose initial value is the value of the instance variable.
Is it a bug or a feature?
The text was updated successfully, but these errors were encountered: