OLD | NEW |
---|---|
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 analyzer.src.generated.resolver; | 5 library analyzer.src.generated.resolver; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
(...skipping 1241 matching lines...) Loading... | |
1252 // evaluation. | 1252 // evaluation. |
1253 ConstructorElement constructor = node.staticElement; | 1253 ConstructorElement constructor = node.staticElement; |
1254 if (constructor != null) { | 1254 if (constructor != null) { |
1255 ConstantEvaluationEngine evaluationEngine = | 1255 ConstantEvaluationEngine evaluationEngine = |
1256 new ConstantEvaluationEngine(_typeProvider, declaredVariables, | 1256 new ConstantEvaluationEngine(_typeProvider, declaredVariables, |
1257 typeSystem: _typeSystem); | 1257 typeSystem: _typeSystem); |
1258 ConstantVisitor constantVisitor = | 1258 ConstantVisitor constantVisitor = |
1259 new ConstantVisitor(evaluationEngine, _errorReporter); | 1259 new ConstantVisitor(evaluationEngine, _errorReporter); |
1260 evaluationEngine.evaluateConstructorCall( | 1260 evaluationEngine.evaluateConstructorCall( |
1261 node, | 1261 node, |
1262 (node.constructorName.type.type as ParameterizedType).typeArguments, | |
1262 node.argumentList.arguments, | 1263 node.argumentList.arguments, |
1263 constructor, | 1264 constructor, |
1264 constantVisitor, | 1265 constantVisitor, |
1265 _errorReporter); | 1266 _errorReporter); |
1266 } | 1267 } |
1267 } | 1268 } |
1268 _validateInstanceCreationArguments(node); | 1269 _validateInstanceCreationArguments(node); |
1269 return super.visitInstanceCreationExpression(node); | 1270 return super.visitInstanceCreationExpression(node); |
1270 } | 1271 } |
1271 | 1272 |
(...skipping 5050 matching lines...) Loading... | |
6322 _currentFunctionBody = node.body; | 6323 _currentFunctionBody = node.body; |
6323 _enclosingFunction = node.element; | 6324 _enclosingFunction = node.element; |
6324 FunctionType type = _enclosingFunction.type; | 6325 FunctionType type = _enclosingFunction.type; |
6325 InferenceContext.setType(node.body, type.returnType); | 6326 InferenceContext.setType(node.body, type.returnType); |
6326 super.visitConstructorDeclaration(node); | 6327 super.visitConstructorDeclaration(node); |
6327 } finally { | 6328 } finally { |
6328 _currentFunctionBody = outerFunctionBody; | 6329 _currentFunctionBody = outerFunctionBody; |
6329 _enclosingFunction = outerFunction; | 6330 _enclosingFunction = outerFunction; |
6330 } | 6331 } |
6331 ConstructorElementImpl constructor = node.element; | 6332 ConstructorElementImpl constructor = node.element; |
6332 constructor.constantInitializers = | 6333 var clone = new ConstantAstCloner().cloneNodeList; |
Paul Berry
2016/07/21 20:42:14
This hunk shouldn't be necessary.
Jennifer Messerly
2016/07/28 22:28:05
Yay! Reverted!
| |
6333 new ConstantAstCloner().cloneNodeList(node.initializers); | 6334 if (strongMode) { |
6335 // Note: the order of cloning matters; it won't ever go back before the | |
6336 // first token that is cloned. So we have to start with fields, then | |
6337 // parameters, then constructor initializers. | |
Brian Wilkerson
2016/07/21 18:01:49
Do you mean that nodes must be cloned in lexical o
Jennifer Messerly
2016/07/21 18:03:11
yes
| |
6338 var enclosingClass = node.parent as ClassDeclaration; | |
6339 constructor.fieldInitializers = clone(enclosingClass.members | |
6340 .where((m) => m is FieldDeclaration) | |
6341 .expand((f) => f.fields.variables) | |
6342 .toList()); | |
6343 constructor.parameterInitializers = clone(node.parameters.parameters | |
6344 .where((p) => p is DefaultFormalParameter) | |
6345 .toList()); | |
6346 } | |
6347 | |
6348 constructor.constantInitializers = clone(node.initializers); | |
6334 return null; | 6349 return null; |
6335 } | 6350 } |
6336 | 6351 |
6337 @override | 6352 @override |
6338 void visitConstructorDeclarationInScope(ConstructorDeclaration node) { | 6353 void visitConstructorDeclarationInScope(ConstructorDeclaration node) { |
6339 super.visitConstructorDeclarationInScope(node); | 6354 super.visitConstructorDeclarationInScope(node); |
6340 safelyVisitComment(node.documentationComment); | 6355 safelyVisitComment(node.documentationComment); |
6341 } | 6356 } |
6342 | 6357 |
6343 @override | 6358 @override |
(...skipping 4730 matching lines...) Loading... | |
11074 return null; | 11089 return null; |
11075 } | 11090 } |
11076 if (identical(node.staticElement, variable)) { | 11091 if (identical(node.staticElement, variable)) { |
11077 if (node.inSetterContext()) { | 11092 if (node.inSetterContext()) { |
11078 result = true; | 11093 result = true; |
11079 } | 11094 } |
11080 } | 11095 } |
11081 return null; | 11096 return null; |
11082 } | 11097 } |
11083 } | 11098 } |
OLD | NEW |