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

Side by Side Diff: pkg/compiler/lib/src/elements/modelx.dart

Issue 1936463002: Fix invariant breakage on erroneous constant variables. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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
« no previous file with comments | « pkg/compiler/lib/src/constants/expressions.dart ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 elements.modelx; 5 library elements.modelx;
6 6
7 import '../common.dart'; 7 import '../common.dart';
8 import '../common/resolution.dart' show Resolution, ParsingContext; 8 import '../common/resolution.dart' show Resolution, ParsingContext;
9 import '../compiler.dart' show Compiler; 9 import '../compiler.dart' show Compiler;
10 import '../constants/constant_constructors.dart'; 10 import '../constants/constant_constructors.dart';
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1401 message: "Constant has not been computed for $this.")); 1401 message: "Constant has not been computed for $this."));
1402 return constantCache; 1402 return constantCache;
1403 } 1403 }
1404 1404
1405 void set constant(ConstantExpression value) { 1405 void set constant(ConstantExpression value) {
1406 if (isPatch) { 1406 if (isPatch) {
1407 ConstantVariableMixin originVariable = origin; 1407 ConstantVariableMixin originVariable = origin;
1408 originVariable.constant = value; 1408 originVariable.constant = value;
1409 return; 1409 return;
1410 } 1410 }
1411 if (constantCache != null &&
1412 constantCache.kind == ConstantExpressionKind.ERRONEOUS) {
1413 // TODO(johnniwinther): Find out why we sometimes compute a non-erroneous
1414 // constant for a variable already known to be erroneous.
1415 return;
1416 }
1411 assert(invariant(this, constantCache == null || constantCache == value, 1417 assert(invariant(this, constantCache == null || constantCache == value,
1412 message: "Constant has already been computed for $this. " 1418 message: "Constant has already been computed for $this. "
1413 "Existing constant: " 1419 "Existing constant: "
1414 "${constantCache != null ? constantCache.toDartText() : ''}, " 1420 "${constantCache != null ? constantCache.toStructuredText() : ''}, "
1415 "New constant: ${value != null ? value.toDartText() : ''}.")); 1421 "New constant: ${value != null ? value.toStructuredText() : ''}."));
1416 constantCache = value; 1422 constantCache = value;
1417 } 1423 }
1418 } 1424 }
1419 1425
1420 abstract class VariableElementX extends ElementX 1426 abstract class VariableElementX extends ElementX
1421 with AstElementMixin, ConstantVariableMixin 1427 with AstElementMixin, ConstantVariableMixin
1422 implements VariableElement { 1428 implements VariableElement {
1423 final Token token; 1429 final Token token;
1424 final VariableList variables; 1430 final VariableList variables;
1425 VariableDefinitions definitionsCache; 1431 VariableDefinitions definitionsCache;
(...skipping 1848 matching lines...) Expand 10 before | Expand all | Expand 10 after
3274 if (definingElement.isField) { 3280 if (definingElement.isField) {
3275 FieldElement field = definingElement; 3281 FieldElement field = definingElement;
3276 body = field.initializer; 3282 body = field.initializer;
3277 } else if (node != null && node.asFunctionExpression() != null) { 3283 } else if (node != null && node.asFunctionExpression() != null) {
3278 body = node.asFunctionExpression().body; 3284 body = node.asFunctionExpression().body;
3279 } 3285 }
3280 return new ParsedResolvedAst( 3286 return new ParsedResolvedAst(
3281 declaration, node, body, definingElement.treeElements); 3287 declaration, node, body, definingElement.treeElements);
3282 } 3288 }
3283 } 3289 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/constants/expressions.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698