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

Side by Side Diff: pkg/compiler/lib/src/resolution/resolution.dart

Issue 2118763002: Revert "Handle fields with initializers in constant constructors." (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: 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) 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 library dart2js.resolution; 5 library dart2js.resolution;
6 6
7 import 'dart:collection' show Queue; 7 import 'dart:collection' show Queue;
8 8
9 import '../common.dart'; 9 import '../common.dart';
10 import '../common/names.dart' show Identifiers; 10 import '../common/names.dart' show Identifiers;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 import '../tree/tree.dart'; 46 import '../tree/tree.dart';
47 import '../universe/call_structure.dart' show CallStructure; 47 import '../universe/call_structure.dart' show CallStructure;
48 import '../universe/use.dart' show StaticUse, TypeUse; 48 import '../universe/use.dart' show StaticUse, TypeUse;
49 import '../universe/world_impact.dart' show WorldImpact; 49 import '../universe/world_impact.dart' show WorldImpact;
50 import '../util/util.dart' show Link, Setlet; 50 import '../util/util.dart' show Link, Setlet;
51 import 'class_hierarchy.dart'; 51 import 'class_hierarchy.dart';
52 import 'class_members.dart' show MembersCreator; 52 import 'class_members.dart' show MembersCreator;
53 import 'constructors.dart'; 53 import 'constructors.dart';
54 import 'members.dart'; 54 import 'members.dart';
55 import 'registry.dart'; 55 import 'registry.dart';
56 import 'resolution_result.dart';
57 import 'scope.dart' show MutableScope; 56 import 'scope.dart' show MutableScope;
58 import 'signatures.dart'; 57 import 'signatures.dart';
59 import 'tree_elements.dart'; 58 import 'tree_elements.dart';
60 import 'typedefs.dart'; 59 import 'typedefs.dart';
61 60
62 class ResolverTask extends CompilerTask { 61 class ResolverTask extends CompilerTask {
63 final ConstantCompiler constantCompiler; 62 final ConstantCompiler constantCompiler;
64 final Compiler compiler; 63 final Compiler compiler;
65 64
66 ResolverTask(Compiler compiler, this.constantCompiler) 65 ResolverTask(Compiler compiler, this.constantCompiler)
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // happens for enum fields where the type is known but is not in the 380 // happens for enum fields where the type is known but is not in the
382 // synthesized AST. 381 // synthesized AST.
383 element.variables.type = const DynamicType(); 382 element.variables.type = const DynamicType();
384 } 383 }
385 384
386 Expression initializer = element.initializer; 385 Expression initializer = element.initializer;
387 Modifiers modifiers = element.modifiers; 386 Modifiers modifiers = element.modifiers;
388 if (initializer != null) { 387 if (initializer != null) {
389 // TODO(johnniwinther): Avoid analyzing initializers if 388 // TODO(johnniwinther): Avoid analyzing initializers if
390 // [Compiler.analyzeSignaturesOnly] is set. 389 // [Compiler.analyzeSignaturesOnly] is set.
391 ResolutionResult result = visitor.visit(initializer); 390 visitor.visit(initializer);
392 if (result.isConstant) {
393 element.constant = result.constant;
394 }
395 } else if (modifiers.isConst) { 391 } else if (modifiers.isConst) {
396 reporter.reportErrorMessage( 392 reporter.reportErrorMessage(
397 element, MessageKind.CONST_WITHOUT_INITIALIZER); 393 element, MessageKind.CONST_WITHOUT_INITIALIZER);
398 } else if (modifiers.isFinal && !element.isInstanceMember) { 394 } else if (modifiers.isFinal && !element.isInstanceMember) {
399 reporter.reportErrorMessage( 395 reporter.reportErrorMessage(
400 element, MessageKind.FINAL_WITHOUT_INITIALIZER); 396 element, MessageKind.FINAL_WITHOUT_INITIALIZER);
401 } else { 397 } else {
402 // TODO(johnniwinther): Register a feature instead. 398 // TODO(johnniwinther): Register a feature instead.
403 registry.registerTypeUse(new TypeUse.instantiation(coreTypes.nullType)); 399 registry.registerTypeUse(new TypeUse.instantiation(coreTypes.nullType));
404 } 400 }
(...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 TreeElements get treeElements { 1123 TreeElements get treeElements {
1128 assert(invariant(this, _treeElements != null, 1124 assert(invariant(this, _treeElements != null,
1129 message: "TreeElements have not been computed for $this.")); 1125 message: "TreeElements have not been computed for $this."));
1130 return _treeElements; 1126 return _treeElements;
1131 } 1127 }
1132 1128
1133 void reuseElement() { 1129 void reuseElement() {
1134 _treeElements = null; 1130 _treeElements = null;
1135 } 1131 }
1136 } 1132 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/constructors.dart ('k') | tests/compiler/dart2js/constant_expression_evaluate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698