| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 dart2js.resolution.variables; | 5 library dart2js.resolution.variables; |
| 6 | 6 |
| 7 import '../common.dart'; | 7 import '../common.dart'; |
| 8 import '../common/resolution.dart'; | 8 import '../common/resolution.dart'; |
| 9 import '../elements/modelx.dart' show LocalVariableElementX, VariableList; | 9 import '../elements/modelx.dart' show LocalVariableElementX, VariableList; |
| 10 import '../tree/tree.dart'; | 10 import '../tree/tree.dart'; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 new VariableDefinitionScope(resolver.scope, name); | 35 new VariableDefinitionScope(resolver.scope, name); |
| 36 resolver.visitIn(node.arguments.head, scope); | 36 resolver.visitIn(node.arguments.head, scope); |
| 37 if (scope.variableReferencedInInitializer) { | 37 if (scope.variableReferencedInInitializer) { |
| 38 reporter.reportErrorMessage(identifier, | 38 reporter.reportErrorMessage(identifier, |
| 39 MessageKind.REFERENCE_IN_INITIALIZATION, {'variableName': name}); | 39 MessageKind.REFERENCE_IN_INITIALIZATION, {'variableName': name}); |
| 40 } | 40 } |
| 41 return identifier; | 41 return identifier; |
| 42 } | 42 } |
| 43 | 43 |
| 44 Identifier visitIdentifier(Identifier node) { | 44 Identifier visitIdentifier(Identifier node) { |
| 45 // The variable is initialized to null. | 45 if (!resolver.inCatchParameters) { |
| 46 registry.registerFeature(Feature.LOCAL_WITHOUT_INITIALIZER); | 46 // The variable is initialized to null. |
| 47 registry.registerFeature(Feature.LOCAL_WITHOUT_INITIALIZER); |
| 48 } |
| 47 if (definitions.modifiers.isConst) { | 49 if (definitions.modifiers.isConst) { |
| 48 if (resolver.inLoopVariable) { | 50 if (resolver.inLoopVariable) { |
| 49 reporter.reportErrorMessage(node, MessageKind.CONST_LOOP_VARIABLE); | 51 reporter.reportErrorMessage(node, MessageKind.CONST_LOOP_VARIABLE); |
| 50 } else { | 52 } else { |
| 51 reporter.reportErrorMessage( | 53 reporter.reportErrorMessage( |
| 52 node, MessageKind.CONST_WITHOUT_INITIALIZER); | 54 node, MessageKind.CONST_WITHOUT_INITIALIZER); |
| 53 } | 55 } |
| 54 } | 56 } |
| 55 if (definitions.modifiers.isFinal && !resolver.inLoopVariable) { | 57 if (definitions.modifiers.isFinal && !resolver.inLoopVariable) { |
| 56 reporter.reportErrorMessage(node, MessageKind.FINAL_WITHOUT_INITIALIZER); | 58 reporter.reportErrorMessage(node, MessageKind.FINAL_WITHOUT_INITIALIZER); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 67 resolver.addToScope(element); | 69 resolver.addToScope(element); |
| 68 if (definitions.modifiers.isConst) { | 70 if (definitions.modifiers.isConst) { |
| 69 addDeferredAction(element, () { | 71 addDeferredAction(element, () { |
| 70 element.constant = | 72 element.constant = |
| 71 resolution.resolver.constantCompiler.compileConstant(element); | 73 resolution.resolver.constantCompiler.compileConstant(element); |
| 72 }); | 74 }); |
| 73 } | 75 } |
| 74 } | 76 } |
| 75 } | 77 } |
| 76 } | 78 } |
| OLD | NEW |