Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(385)

Unified Diff: dart/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 60293003: Version 0.8.10.5 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: dart/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart
===================================================================
--- dart/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart (revision 29908)
+++ dart/sdk/lib/_internal/compiler/implementation/compile_time_constants.dart (working copy)
@@ -114,21 +114,33 @@
Node right = assignment.arguments.head;
value =
compileNodeWithDefinitions(right, definitions, isConst: isConst);
- if (compiler.enableTypeAssertions
- && value != null
- && element.isField()) {
+ if (compiler.enableTypeAssertions &&
+ value != null &&
+ element.isField()) {
DartType elementType = element.computeType(compiler);
- DartType constantType = value.computeType(compiler);
- if (!constantSystem.isSubtype(compiler, constantType, elementType)) {
+ if (elementType.kind == TypeKind.MALFORMED_TYPE && !value.isNull()) {
if (isConst) {
+ ErroneousElement element = elementType.element;
compiler.reportFatalError(
- node, MessageKind.NOT_ASSIGNABLE.error,
- {'fromType': constantType, 'toType': elementType});
+ node, element.messageKind, element.messageArguments);
} else {
- // If the field cannot be lazily initialized, we will throw
- // the exception at runtime.
+ // We need to throw an exception at runtime.
value = null;
}
+ } else {
+ DartType constantType = value.computeType(compiler);
+ if (!constantSystem.isSubtype(compiler,
+ constantType, elementType)) {
+ if (isConst) {
+ compiler.reportFatalError(
+ node, MessageKind.NOT_ASSIGNABLE.error,
+ {'fromType': constantType, 'toType': elementType});
+ } else {
+ // If the field cannot be lazily initialized, we will throw
+ // the exception at runtime.
+ value = null;
+ }
+ }
}
}
}
« no previous file with comments | « dart/samples/dartiverse_search/web/client.dart ('k') | dart/sdk/lib/_internal/compiler/implementation/elements/elements.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698