OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library kernel.transformations.closure.invalidate; | 5 library kernel.transformations.closure.invalidate; |
6 | 6 |
7 import '../../ast.dart'; | 7 import '../../ast.dart'; |
8 | 8 |
9 class InvalidateClosures extends Transformer { | 9 class InvalidateClosures extends Transformer { |
10 FunctionDeclaration visitFunctionDeclaration(FunctionDeclaration node) { | 10 FunctionDeclaration visitFunctionDeclaration(FunctionDeclaration node) { |
11 invalidate(node.function); | 11 invalidate(node.function); |
12 return node; | 12 return node; |
13 } | 13 } |
14 | 14 |
15 FunctionExpression visitFunctionExpression(FunctionExpression node) { | 15 FunctionExpression visitFunctionExpression(FunctionExpression node) { |
16 invalidate(node.function); | 16 invalidate(node.function); |
17 return node; | 17 return node; |
18 } | 18 } |
19 | 19 |
20 void invalidate(FunctionNode function) { | 20 void invalidate(FunctionNode function) { |
| 21 if (function.asyncMarker != AsyncMarker.Sync) return; |
21 var position = function.location; | 22 var position = function.location; |
22 function.body = new ExpressionStatement(new Throw( | 23 function.body = new ExpressionStatement(new Throw( |
23 new StringLiteral("Calling unconverted closure at $position"))) | 24 new StringLiteral("Calling unconverted closure at $position"))) |
24 ..parent = function; | 25 ..parent = function; |
25 } | 26 } |
26 } | 27 } |
OLD | NEW |