Index: pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart |
diff --git a/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart b/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart |
index 1f5fea0e4ab43f379a60c2e3fe484ec279471075..691e206adfad569c27630d3e1cb4b29f5f85bf1f 100644 |
--- a/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart |
+++ b/pkg/compiler/lib/src/tree_ir/optimization/statement_rewriter.dart |
@@ -347,8 +347,17 @@ class StatementRewriter extends Transformer implements Pass { |
} |
Expression visitInvokeMethod(InvokeMethod node) { |
- _rewriteList(node.arguments); |
- node.receiver = visitExpression(node.receiver); |
+ if (node.receiverIsNotNull) { |
+ _rewriteList(node.arguments); |
+ node.receiver = visitExpression(node.receiver); |
+ } else { |
+ // Impure expressions cannot be propagated across the method lookup, |
+ // because it throws when the receiver is null. |
+ inEmptyEnvironment(() { |
+ _rewriteList(node.arguments); |
+ }); |
+ node.receiver = visitExpression(node.receiver); |
+ } |
return node; |
} |