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

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

Issue 2015903002: Compute and check members for serialization (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix invariant Created 4 years, 6 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC); 352 MessageKind.TOP_LEVEL_VARIABLE_DECLARED_STATIC);
353 } 353 }
354 ResolverVisitor visitor = visitorFor(element); 354 ResolverVisitor visitor = visitorFor(element);
355 ResolutionRegistry registry = visitor.registry; 355 ResolutionRegistry registry = visitor.registry;
356 // TODO(johnniwinther): Maybe remove this when placeholderCollector migrates 356 // TODO(johnniwinther): Maybe remove this when placeholderCollector migrates
357 // to the backend ast. 357 // to the backend ast.
358 registry.defineElement(tree.definitions.nodes.head, element); 358 registry.defineElement(tree.definitions.nodes.head, element);
359 // TODO(johnniwinther): Share the resolved type between all variables 359 // TODO(johnniwinther): Share the resolved type between all variables
360 // declared in the same declaration. 360 // declared in the same declaration.
361 if (tree.type != null) { 361 if (tree.type != null) {
362 element.variables.type = visitor.resolveTypeAnnotation(tree.type); 362 DartType type = visitor.resolveTypeAnnotation(tree.type);
363 } else { 363 assert(invariant(
364 element,
365 element.variables.type == null ||
366 // Crude check but we have no equivalence relation that
367 // equates malformed types, like matching creations of type
368 // `Foo<Unresolved>`.
369 element.variables.type.toString() == type.toString(),
370 message: "Unexpected type computed for $element. "
371 "Was ${element.variables.type}, computed $type."));
372 element.variables.type = type;
373 } else if (element.variables.type == null) {
374 // Only assign the dynamic type if the element has no known type. This
375 // happens for enum fields where the type is known but is not in the
376 // synthesized AST.
364 element.variables.type = const DynamicType(); 377 element.variables.type = const DynamicType();
365 } 378 }
366 379
367 Expression initializer = element.initializer; 380 Expression initializer = element.initializer;
368 Modifiers modifiers = element.modifiers; 381 Modifiers modifiers = element.modifiers;
369 if (initializer != null) { 382 if (initializer != null) {
370 // TODO(johnniwinther): Avoid analyzing initializers if 383 // TODO(johnniwinther): Avoid analyzing initializers if
371 // [Compiler.analyzeSignaturesOnly] is set. 384 // [Compiler.analyzeSignaturesOnly] is set.
372 visitor.visit(initializer); 385 visitor.visit(initializer);
373 } else if (modifiers.isConst) { 386 } else if (modifiers.isConst) {
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
1104 TreeElements get treeElements { 1117 TreeElements get treeElements {
1105 assert(invariant(this, _treeElements != null, 1118 assert(invariant(this, _treeElements != null,
1106 message: "TreeElements have not been computed for $this.")); 1119 message: "TreeElements have not been computed for $this."));
1107 return _treeElements; 1120 return _treeElements;
1108 } 1121 }
1109 1122
1110 void reuseElement() { 1123 void reuseElement() {
1111 _treeElements = null; 1124 _treeElements = null;
1112 } 1125 }
1113 } 1126 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698