Skip to content
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

Open
FMorschel opened this issue Dec 12, 2024 · 1 comment
Open

Evaluations should work for runtimeType #59711

FMorschel opened this issue Dec 12, 2024 · 1 comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.

Comments

@FMorschel
Copy link
Contributor

Say you have

class A {}

class B extends A {
  int foo() => 0;
}

class C {
  C(this.a);
  A a;
}

void main() {
  var c = C(B());  // Breakpoint here 
}

Now you try to evaluate c.a.foo() it gives you an error message about foo not being defined for A. But if you do (c.a as dynamic).foo() everything works normally and it can result in 0 here.

Could the evaluations do something like this internally?

// CC @DanTup

@FMorschel FMorschel added the area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends. label Dec 12, 2024
@mraleph
Copy link
Member

mraleph commented Dec 13, 2024

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. c would be dynamic and consequently c.a would be dynamic as well), but that hits a problem that any features which rely on static type and type inference (e.g. extensions and extension types or generics) don't work as one would expect.

Making c.a.foo work reliably across all possibilities requires some sophisticated machinery because it requires parser to somehow be able to introspect runtime state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-vm Use area-vm for VM related issues, including code coverage, and the AOT and JIT backends.
Projects
None yet
Development

No branches or pull requests

2 participants