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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/compile_time_constants.dart

Issue 24211003: Let the inferrer know that lazy variables can also be null incase their initializer throws. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/resolution/members.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of dart2js; 5 part of dart2js;
6 6
7 /** 7 /**
8 * The [ConstantHandler] keeps track of compile-time constants, 8 * The [ConstantHandler] keeps track of compile-time constants,
9 * initializations of global and static fields, and default values of 9 * initializations of global and static fields, and default values of
10 * optional parameters. 10 * optional parameters.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 && value != null 198 && value != null
199 && element.isField()) { 199 && element.isField()) {
200 DartType elementType = element.computeType(compiler); 200 DartType elementType = element.computeType(compiler);
201 DartType constantType = value.computeType(compiler); 201 DartType constantType = value.computeType(compiler);
202 if (!constantSystem.isSubtype(compiler, constantType, elementType)) { 202 if (!constantSystem.isSubtype(compiler, constantType, elementType)) {
203 if (isConst) { 203 if (isConst) {
204 compiler.reportFatalError( 204 compiler.reportFatalError(
205 node, MessageKind.NOT_ASSIGNABLE.error, 205 node, MessageKind.NOT_ASSIGNABLE.error,
206 {'fromType': constantType, 'toType': elementType}); 206 {'fromType': constantType, 'toType': elementType});
207 } else { 207 } else {
208 // If the field can be lazily initialized, we will throw 208 // If the field cannot be lazily initialized, we will throw
209 // the exception at runtime. 209 // the exception at runtime.
210 value = null; 210 value = null;
211 } 211 }
212 } 212 }
213 } 213 }
214 } 214 }
215 if (value != null) { 215 if (value != null) {
216 initialVariableValues[element] = value; 216 initialVariableValues[element] = value;
217 } else { 217 } else {
218 assert(!isConst); 218 assert(!isConst);
(...skipping 743 matching lines...) Expand 10 before | Expand all | Expand 10 after
962 if (fieldValue == null) { 962 if (fieldValue == null) {
963 // Use the default value. 963 // Use the default value.
964 fieldValue = handler.compileConstant(field); 964 fieldValue = handler.compileConstant(field);
965 } 965 }
966 jsNewArguments.add(fieldValue); 966 jsNewArguments.add(fieldValue);
967 }, 967 },
968 includeSuperAndInjectedMembers: true); 968 includeSuperAndInjectedMembers: true);
969 return jsNewArguments; 969 return jsNewArguments;
970 } 970 }
971 } 971 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/_internal/compiler/implementation/resolution/members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698