| 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.dart.constant.evaluation; | 5 library analyzer.src.dart.constant.evaluation; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/context/declared_variables.dart'; | 9 import 'package:analyzer/context/declared_variables.dart'; |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } else if (constant.isFactory) { | 288 } else if (constant.isFactory) { |
| 289 // Factory constructor, but getConstRedirectedConstructor returned | 289 // Factory constructor, but getConstRedirectedConstructor returned |
| 290 // null. This can happen if we're visiting one of the special externa
l | 290 // null. This can happen if we're visiting one of the special externa
l |
| 291 // const factory constructors in the SDK, or if the code contains | 291 // const factory constructors in the SDK, or if the code contains |
| 292 // errors (such as delegating to a non-const constructor, or delegatin
g | 292 // errors (such as delegating to a non-const constructor, or delegatin
g |
| 293 // to a constructor that can't be resolved). In any of these cases, | 293 // to a constructor that can't be resolved). In any of these cases, |
| 294 // we'll evaluate calls to this constructor without having to refer to | 294 // we'll evaluate calls to this constructor without having to refer to |
| 295 // any other constants. So we don't need to report any dependencies. | 295 // any other constants. So we don't need to report any dependencies. |
| 296 return; | 296 return; |
| 297 } | 297 } |
| 298 bool superInvocationFound = false; | 298 bool defaultSuperInvocationNeeded = true; |
| 299 List<ConstructorInitializer> initializers = | 299 List<ConstructorInitializer> initializers = |
| 300 constant.constantInitializers; | 300 constant.constantInitializers; |
| 301 for (ConstructorInitializer initializer in initializers) { | 301 for (ConstructorInitializer initializer in initializers) { |
| 302 if (initializer is SuperConstructorInvocation) { | 302 if (initializer is SuperConstructorInvocation || |
| 303 superInvocationFound = true; | 303 initializer is RedirectingConstructorInvocation) { |
| 304 defaultSuperInvocationNeeded = false; |
| 304 } | 305 } |
| 305 initializer.accept(referenceFinder); | 306 initializer.accept(referenceFinder); |
| 306 } | 307 } |
| 307 if (!superInvocationFound) { | 308 if (defaultSuperInvocationNeeded) { |
| 308 // No explicit superconstructor invocation found, so we need to | 309 // No explicit superconstructor invocation found, so we need to |
| 309 // manually insert a reference to the implicit superconstructor. | 310 // manually insert a reference to the implicit superconstructor. |
| 310 InterfaceType superclass = | 311 InterfaceType superclass = |
| 311 (constant.returnType as InterfaceType).superclass; | 312 (constant.returnType as InterfaceType).superclass; |
| 312 if (superclass != null && !superclass.isObject) { | 313 if (superclass != null && !superclass.isObject) { |
| 313 ConstructorElement unnamedConstructor = | 314 ConstructorElement unnamedConstructor = |
| 314 getConstructorImpl(superclass.element.unnamedConstructor); | 315 getConstructorImpl(superclass.element.unnamedConstructor); |
| 315 if (unnamedConstructor != null) { | 316 if (unnamedConstructor != null) { |
| 316 callback(unnamedConstructor); | 317 callback(unnamedConstructor); |
| 317 } | 318 } |
| (...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1994 } | 1995 } |
| 1995 | 1996 |
| 1996 @override | 1997 @override |
| 1997 String toString() { | 1998 String toString() { |
| 1998 if (value == null) { | 1999 if (value == null) { |
| 1999 return "error"; | 2000 return "error"; |
| 2000 } | 2001 } |
| 2001 return value.toString(); | 2002 return value.toString(); |
| 2002 } | 2003 } |
| 2003 } | 2004 } |
| OLD | NEW |