-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Evaluations should work for runtimeType #59711
Comments
Right now evaluated expression are compiled as Dart code. So you can only do things which are expressible in Dart. We used to compile expressions without preserving static types (e.g. Making |
I am not sure if it is a good idea for the VM or CFE to evaluate the expression differently from how it would behave when the code is normally run. |
The problem currently is that the expression is not running normally, but actually giving out an error. While on code it does run just fine. |
I modified your code as follows
and tried running it, this is what I get
|
Yeah. The code where I saw the example was inside one of the files for the analyzer and it was tested for the type with if case. It also shows different getters in the evaluation hover and such. That is why I thought it should work. |
The expression evaluator does not have the context of the type testing that the code you were running has. |
I'm actually confused... The original code where @FMorschel saw this was like this: And the evaluation failed like this: However, in a simple test of what I think is the same, I actually don't get an error - I am allowed to evaluate void main() {
f(B('test'));
}
void f(A a) {
print(a);
}
class A {}
class B extends A {
final String x;
B(this.x);
} I don't understand why these are different.
I can understand that, but I also feel like having to add |
Say you have
Now you try to evaluate
c.a.foo()
it gives you an error message aboutfoo
not being defined forA
. But if you do(c.a as dynamic).foo()
everything works normally and it can result in0
here.Could the evaluations do something like this internally?
// CC @DanTup
The text was updated successfully, but these errors were encountered: