-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fasta: Don't emit invalid-statement for redirecting factories #28424
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
Comments
Redirecting factories are eliminated in the front-end. Originally they were converted to a procedure that called the target, but the analyzer's element model does not expose default parameter values, and thus we cannot generate a forwarding procedure without loading the full source code of the target. The constructor in Foo is inserted by the sanitize_for_vm pass to ensure all classes have at least one procedure or constructor, because otherwise the VM crashes. |
Some tests pass I think if the input to dartk is perfectly valid and sound code, the IR should not contain any invalud-* nodes. |
CL for fix https://codereview.chromium.org/2638303002/ |
The fix, to not use invalid statement, seems good. I'll just note here that the VM doesn't crash, it hits an assertion failure in debug builds, and that assertion seems to be just a sanity-check precondition and not a correctness precondition. Running in a release build or without the assertion in a debug build does not seem to fail. |
Maybe a better way to formulate this is: The VM does not expect to ever encounter an |
I completely agree - we should get rid of all invalid nodes. |
factory Name() = OtherClass
This test still crashes with fasta and Also see #28421 |
Blocked on #29841 |
There is btw also a test, which invokes a redirecting factory via class A {
factory A(
String // //# 01: static type warning
x) = B;
A._();
}
class B extends A {
var x;
B(int x)
: super._(),
this.x = x;
}
main() {
var cm = reflectClass(A);
// The type-annotation in A's constructor must be ignored.
var b = cm.newInstance(const Symbol(''), [499]).reflectee;
Expect.equals(499, b.x);
Expect.throws(
() => cm.newInstance(const Symbol(''), ["str"]), (e) => e is TypeError);
} from |
Fixed in 300a2ea. |
Dartk translates
to
It should not emit
invalid-statement
./cc @kmillikin & #28263
The text was updated successfully, but these errors were encountered: