-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Open
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)web-dart2js
Description
In the following code:
class Super {
Super();
factory Super.sub() = Sub;
void foo() {
throw "super foo";
}
void bar() {
foo();
// Throw to avoid inlining this method.
throw "";
}
}
class Sub extends Super {
void foo() {
throw "sub foo";
}
}
main() async {
new Super.sub().bar();
}
Super.foo()
is unreachable, but dart2js (as of 0c005a3) fails to tree-shake it:
$ dart2js test.dart
$ grep -n "super error" out.js
4936: throw H.wrapException("super foo");
This seems to only happen if Sub
is constructed via a factory constructor on Super
(redirecting or otherwise), and foo()
is called from another method in Super
(in this case, bar()
).
This came up in practice when trying to reduce the code size of the http
package and its dependencies.
srawlins
Metadata
Metadata
Assignees
Labels
area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.Issues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)Incorrect behavior (everything from a crash to more subtle misbehavior)web-dart2js