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

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

Issue 2104843002: Handle fields with initializers in constant constructors. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix invariants Created 4 years, 5 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
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 1401 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 ConstantVariableMixin originVariable = origin; 1412 ConstantVariableMixin originVariable = origin;
1413 originVariable.constant = value; 1413 originVariable.constant = value;
1414 return; 1414 return;
1415 } 1415 }
1416 if (constantCache != null && 1416 if (constantCache != null &&
1417 constantCache.kind == ConstantExpressionKind.ERRONEOUS) { 1417 constantCache.kind == ConstantExpressionKind.ERRONEOUS) {
1418 // TODO(johnniwinther): Find out why we sometimes compute a non-erroneous 1418 // TODO(johnniwinther): Find out why we sometimes compute a non-erroneous
1419 // constant for a variable already known to be erroneous. 1419 // constant for a variable already known to be erroneous.
1420 return; 1420 return;
1421 } 1421 }
1422 assert(invariant(this, constantCache == null || constantCache == value, 1422 if (constantCache != null && constantCache != value) {
1423 message: "Constant has already been computed for $this. " 1423 // Allow setting the constant as erroneous. Constants computed during
1424 "Existing constant: " 1424 // resolution are locally valid but might be effectively erroneous. For
1425 "${constantCache != null ? constantCache.toStructuredText() : ''}, " 1425 // instance `a ? true : false` where a is `const a = m()`. Since `a` is
1426 "New constant: ${value != null ? value.toStructuredText() : ''}.")); 1426 // declared to be constant, the conditional is assumed valid, but when
1427 // computing the value we see that it isn't.
1428 // TODO(johnniwinther): Remove this exception when all constant
1429 // expressions are computed during resolution.
1430 assert(invariant(this, value.kind == ConstantExpressionKind.ERRONEOUS,
1431 message: "Constant has already been computed for $this. "
1432 "Existing constant: "
1433 "${constantCache != null ? constantCache.toStructuredText() : ''}"
1434 ", New constant: "
1435 "${value != null ? value.toStructuredText() : ''}."));
1436 }
1427 constantCache = value; 1437 constantCache = value;
1428 } 1438 }
1429 } 1439 }
1430 1440
1431 abstract class VariableElementX extends ElementX 1441 abstract class VariableElementX extends ElementX
1432 with AstElementMixin, ConstantVariableMixin 1442 with AstElementMixin, ConstantVariableMixin
1433 implements VariableElement { 1443 implements VariableElement {
1434 final Token token; 1444 final Token token;
1435 final VariableList variables; 1445 final VariableList variables;
1436 VariableDefinitions definitionsCache; 1446 VariableDefinitions definitionsCache;
(...skipping 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
3293 body = node.asFunctionExpression().body; 3303 body = node.asFunctionExpression().body;
3294 } 3304 }
3295 return new ParsedResolvedAst( 3305 return new ParsedResolvedAst(
3296 declaration, 3306 declaration,
3297 node, 3307 node,
3298 body, 3308 body,
3299 definingElement.treeElements, 3309 definingElement.treeElements,
3300 definingElement.compilationUnit.script.resourceUri); 3310 definingElement.compilationUnit.script.resourceUri);
3301 } 3311 }
3302 } 3312 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698