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

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/names.dart' show Identifiers; 8 import '../common/names.dart' show Identifiers;
9 import '../common/resolution.dart' show Resolution, ParsingContext; 9 import '../common/resolution.dart' show Resolution, ParsingContext;
10 import '../compiler.dart' show Compiler; 10 import '../compiler.dart' show Compiler;
(...skipping 1407 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 ConstantVariableMixin originVariable = origin; 1418 ConstantVariableMixin originVariable = origin;
1419 originVariable.constant = value; 1419 originVariable.constant = value;
1420 return; 1420 return;
1421 } 1421 }
1422 if (constantCache != null && 1422 if (constantCache != null &&
1423 constantCache.kind == ConstantExpressionKind.ERRONEOUS) { 1423 constantCache.kind == ConstantExpressionKind.ERRONEOUS) {
1424 // TODO(johnniwinther): Find out why we sometimes compute a non-erroneous 1424 // TODO(johnniwinther): Find out why we sometimes compute a non-erroneous
1425 // constant for a variable already known to be erroneous. 1425 // constant for a variable already known to be erroneous.
1426 return; 1426 return;
1427 } 1427 }
1428 assert(invariant(this, constantCache == null || constantCache == value, 1428 if (constantCache != null && constantCache != value) {
1429 message: "Constant has already been computed for $this. " 1429 // Allow setting the constant as erroneous. Constants computed during
1430 "Existing constant: " 1430 // resolution are locally valid but might be effectively erroneous. For
1431 "${constantCache != null ? constantCache.toStructuredText() : ''}, " 1431 // instance `a ? true : false` where a is `const a = m()`. Since `a` is
1432 "New constant: ${value != null ? value.toStructuredText() : ''}.")); 1432 // declared to be constant, the conditional is assumed valid, but when
1433 // computing the value we see that it isn't.
1434 // TODO(johnniwinther): Remove this exception when all constant
1435 // expressions are computed during resolution.
1436 assert(invariant(
1437 this, value == null || value.kind == ConstantExpressionKind.ERRONEOUS,
1438 message: "Constant has already been computed for $this. "
1439 "Existing constant: "
1440 "${constantCache != null ? constantCache.toStructuredText() : ''}"
1441 ", New constant: "
1442 "${value != null ? value.toStructuredText() : ''}."));
1443 }
1433 constantCache = value; 1444 constantCache = value;
1434 } 1445 }
1435 } 1446 }
1436 1447
1437 abstract class VariableElementX extends ElementX 1448 abstract class VariableElementX extends ElementX
1438 with AstElementMixin, ConstantVariableMixin 1449 with AstElementMixin, ConstantVariableMixin
1439 implements VariableElement { 1450 implements VariableElement {
1440 final Token token; 1451 final Token token;
1441 final VariableList variables; 1452 final VariableList variables;
1442 VariableDefinitions definitionsCache; 1453 VariableDefinitions definitionsCache;
(...skipping 1864 matching lines...) Expand 10 before | Expand all | Expand 10 after
3307 body = node.asFunctionExpression().body; 3318 body = node.asFunctionExpression().body;
3308 } 3319 }
3309 return new ParsedResolvedAst( 3320 return new ParsedResolvedAst(
3310 declaration, 3321 declaration,
3311 node, 3322 node,
3312 body, 3323 body,
3313 definingElement.treeElements, 3324 definingElement.treeElements,
3314 definingElement.compilationUnit.script.resourceUri); 3325 definingElement.compilationUnit.script.resourceUri);
3315 } 3326 }
3316 } 3327 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/constants/constant_constructors.dart ('k') | pkg/compiler/lib/src/inferrer/type_graph_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698