Index: pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart |
diff --git a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart |
index e6b8c34597602dc4b2cc88c901b214dc7c930ef8..d91c9111744d3c8701e83308d5a9fa41d91b7f65 100644 |
--- a/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart |
+++ b/pkg/compiler/lib/src/tree_ir/tree_ir_builder.dart |
@@ -625,21 +625,16 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ { |
visitForeignCode(cps_ir.ForeignCode node) { |
List<Expression> arguments = |
node.arguments.map(getVariableUse).toList(growable: false); |
- if (HasCapturedArguments.check(node.codeTemplate.ast)) { |
- for (Expression arg in arguments) { |
- if (arg is VariableUse) { |
- arg.variable.isCaptured = true; |
- } else { |
- // TODO(asgerf): Avoid capture of 'this'. |
- } |
- } |
- } |
+ List<bool> nullableArguments = node.arguments |
+ .map((argument) => argument.definition.type.isNullable) |
+ .toList(growable: false); |
if (node.codeTemplate.isExpression) { |
return new ForeignExpression( |
node.codeTemplate, |
node.type, |
arguments, |
node.nativeBehavior, |
+ nullableArguments, |
node.dependency); |
} else { |
return (Statement next) { |
@@ -649,6 +644,7 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ { |
node.type, |
arguments, |
node.nativeBehavior, |
+ nullableArguments, |
node.dependency); |
}; |
} |
@@ -704,28 +700,3 @@ class Builder implements cps_ir.Visitor/*<NodeCallback|Node>*/ { |
visitContinuation(cps_ir.Continuation node) => unexpectedNode(node); |
visitMutableVariable(cps_ir.MutableVariable node) => unexpectedNode(node); |
} |
- |
-class HasCapturedArguments extends js.BaseVisitor { |
- static bool check(js.Node node) { |
- HasCapturedArguments visitor = new HasCapturedArguments(); |
- node.accept(visitor); |
- return visitor.found; |
- } |
- |
- int enclosingFunctions = 0; |
- bool found = false; |
- |
- @override |
- visitFun(js.Fun node) { |
- ++enclosingFunctions; |
- node.visitChildren(this); |
- --enclosingFunctions; |
- } |
- |
- @override |
- visitInterpolatedNode(js.InterpolatedNode node) { |
- if (enclosingFunctions > 0) { |
- found = true; |
- } |
- } |
-} |