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

Unified 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, 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 side-by-side diff with in-line comments
Download patch
Index: pkg/compiler/lib/src/resolution/resolution.dart
diff --git a/pkg/compiler/lib/src/resolution/resolution.dart b/pkg/compiler/lib/src/resolution/resolution.dart
index 4ea5aff5f2d2f4ce57e97c9e7f00869d71971da0..ea20e3b1fdac15f01393938b689a9452879aa201 100644
--- a/pkg/compiler/lib/src/resolution/resolution.dart
+++ b/pkg/compiler/lib/src/resolution/resolution.dart
@@ -359,8 +359,21 @@ class ResolverTask extends CompilerTask {
// TODO(johnniwinther): Share the resolved type between all variables
// declared in the same declaration.
if (tree.type != null) {
- element.variables.type = visitor.resolveTypeAnnotation(tree.type);
- } else {
+ DartType type = visitor.resolveTypeAnnotation(tree.type);
+ assert(invariant(
+ element,
+ element.variables.type == null ||
+ // Crude check but we have no equivalence relation that
+ // equates malformed types, like matching creations of type
+ // `Foo<Unresolved>`.
+ element.variables.type.toString() == type.toString(),
+ message: "Unexpected type computed for $element. "
+ "Was ${element.variables.type}, computed $type."));
+ element.variables.type = type;
+ } else if (element.variables.type == null) {
+ // Only assign the dynamic type if the element has no known type. This
+ // happens for enum fields where the type is known but is not in the
+ // synthesized AST.
element.variables.type = const DynamicType();
}

Powered by Google App Engine
This is Rietveld 408576698