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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
231 expression = compileNodeWithDefinitions(initializer, definitions, | 231 expression = compileNodeWithDefinitions(initializer, definitions, |
232 isConst: isConst); | 232 isConst: isConst); |
233 if (compiler.options.enableTypeAssertions && | 233 if (compiler.options.enableTypeAssertions && |
234 checkType && | 234 checkType && |
235 expression != null && | 235 expression != null && |
236 element.isField) { | 236 element.isField) { |
237 DartType elementType = element.type; | 237 DartType elementType = element.type; |
238 ConstantValue value = getConstantValue(expression); | 238 ConstantValue value = getConstantValue(expression); |
239 if (elementType.isMalformed && !value.isNull) { | 239 if (elementType.isMalformed && !value.isNull) { |
240 if (isConst) { | 240 if (isConst) { |
241 ErroneousElement element = elementType.element; | 241 if (elementType is MalformedType) { |
Johnni Winther
2016/05/23 12:50:41
Add a TODO for me here; I'm not sure we should gen
eernst
2016/05/23 14:30:23
Done.
| |
242 reporter.reportErrorMessage( | 242 ErroneousElement element = elementType.element; |
243 node, element.messageKind, element.messageArguments); | 243 reporter.reportErrorMessage( |
244 node, element.messageKind, element.messageArguments); | |
245 } else { | |
246 assert(elementType is MethodTypeVariableType); | |
247 reporter.reportErrorMessage( | |
248 node, MessageKind.TYPE_VARIABLE_FROM_METHOD_NOT_REIFIED); | |
249 } | |
244 } else { | 250 } else { |
245 // We need to throw an exception at runtime. | 251 // We need to throw an exception at runtime. |
246 expression = null; | 252 expression = null; |
247 } | 253 } |
248 } else { | 254 } else { |
249 DartType constantType = value.getType(coreTypes); | 255 DartType constantType = value.getType(coreTypes); |
250 if (!constantSystem.isSubtype( | 256 if (!constantSystem.isSubtype( |
251 compiler.types, constantType, elementType)) { | 257 compiler.types, constantType, elementType)) { |
252 if (isConst) { | 258 if (isConst) { |
253 reporter.reportErrorMessage(node, MessageKind.NOT_ASSIGNABLE, | 259 reporter.reportErrorMessage(node, MessageKind.NOT_ASSIGNABLE, |
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1342 class _CompilerEnvironment implements Environment { | 1348 class _CompilerEnvironment implements Environment { |
1343 final Compiler compiler; | 1349 final Compiler compiler; |
1344 | 1350 |
1345 _CompilerEnvironment(this.compiler); | 1351 _CompilerEnvironment(this.compiler); |
1346 | 1352 |
1347 @override | 1353 @override |
1348 String readFromEnvironment(String name) { | 1354 String readFromEnvironment(String name) { |
1349 return compiler.fromEnvironment(name); | 1355 return compiler.fromEnvironment(name); |
1350 } | 1356 } |
1351 } | 1357 } |
OLD | NEW |