| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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.compile_time_constant_evaluator; | 5 library dart2js.compile_time_constant_evaluator; |
| 6 | 6 |
| 7 import 'common.dart'; | 7 import 'common.dart'; |
| 8 import 'common/resolution.dart' show Resolution; | 8 import 'common/resolution.dart' show Resolution; |
| 9 import 'common/tasks.dart' show CompilerTask; | 9 import 'common/tasks.dart' show CompilerTask; |
| 10 import 'compiler.dart' show Compiler; | 10 import 'compiler.dart' show Compiler; |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 expression = compileNodeWithDefinitions(initializer, definitions, | 239 expression = compileNodeWithDefinitions(initializer, definitions, |
| 240 isConst: isConst); | 240 isConst: isConst); |
| 241 if (compiler.options.enableTypeAssertions && | 241 if (compiler.options.enableTypeAssertions && |
| 242 checkType && | 242 checkType && |
| 243 expression != null && | 243 expression != null && |
| 244 element.isField) { | 244 element.isField) { |
| 245 DartType elementType = element.type; | 245 DartType elementType = element.type; |
| 246 ConstantValue value = getConstantValue(expression); | 246 ConstantValue value = getConstantValue(expression); |
| 247 if (elementType.isMalformed && !value.isNull) { | 247 if (elementType.isMalformed && !value.isNull) { |
| 248 if (isConst) { | 248 if (isConst) { |
| 249 // TODO(johnniwinther): Check that it is possible to reach this | 249 ErroneousElement element = elementType.element; |
| 250 // point in a situation where `elementType is! MalformedType`. | 250 reporter.reportErrorMessage( |
| 251 if (elementType is MalformedType) { | 251 node, element.messageKind, element.messageArguments); |
| 252 ErroneousElement element = elementType.element; | |
| 253 reporter.reportErrorMessage( | |
| 254 node, element.messageKind, element.messageArguments); | |
| 255 } else { | |
| 256 assert(elementType is MethodTypeVariableType); | |
| 257 reporter.reportErrorMessage( | |
| 258 node, MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED); | |
| 259 } | |
| 260 } else { | 252 } else { |
| 261 // We need to throw an exception at runtime. | 253 // We need to throw an exception at runtime. |
| 262 expression = null; | 254 expression = null; |
| 263 } | 255 } |
| 264 } else { | 256 } else { |
| 265 DartType constantType = value.getType(coreTypes); | 257 DartType constantType = value.getType(coreTypes); |
| 266 if (!constantSystem.isSubtype( | 258 if (!constantSystem.isSubtype( |
| 267 compiler.types, constantType, elementType)) { | 259 compiler.types, constantType, elementType)) { |
| 268 if (isConst) { | 260 if (isConst) { |
| 269 reporter.reportErrorMessage(node, MessageKind.NOT_ASSIGNABLE, | 261 reporter.reportErrorMessage(node, MessageKind.NOT_ASSIGNABLE, |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1359 class _CompilerEnvironment implements Environment { | 1351 class _CompilerEnvironment implements Environment { |
| 1360 final Compiler compiler; | 1352 final Compiler compiler; |
| 1361 | 1353 |
| 1362 _CompilerEnvironment(this.compiler); | 1354 _CompilerEnvironment(this.compiler); |
| 1363 | 1355 |
| 1364 @override | 1356 @override |
| 1365 String readFromEnvironment(String name) { | 1357 String readFromEnvironment(String name) { |
| 1366 return compiler.fromEnvironment(name); | 1358 return compiler.fromEnvironment(name); |
| 1367 } | 1359 } |
| 1368 } | 1360 } |
| OLD | NEW |