[dart2js] Avoid generating 'return' statement in setter
Setters don't need to return anything. Recognize the
ir.ReturnStatement in
set foo(x) => this._foo = x;
This reduces some large apps that use that style by a few KB.
Change-Id: I87edced1024ab6e596564fa748484d9e07f9f2d7
Reviewed-on: https://dart-review.googlesource.com/c/93368
Reviewed-by: Johnni Winther <johnniwinther@google.com>
Commit-Queue: Stephen Adams <sra@google.com>
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 87234b3..5a4dbe8 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -1579,6 +1579,14 @@
}
}
handleInTryStatement();
+ if (_inliningStack.isEmpty && targetElement.isSetter) {
+ if (node.parent is ir.FunctionNode) {
+ // An arrow function definition of a setter has a ReturnStatemnt as a
+ // body, e.g. "set foo(x) => this._x = x;". There is no way to access
+ // the returned value, so don't emit a return.
+ return;
+ }
+ }
_emitReturn(value, sourceInformation);
}