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

Unified Diff: lib/src/checker/resolver.dart

Issue 1180513002: fix #214, check type of inferred initializing formal with default value (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
Index: lib/src/checker/resolver.dart
diff --git a/lib/src/checker/resolver.dart b/lib/src/checker/resolver.dart
index bd080e970ba0fea76194e9e139a008b9a3834bfb..473923ffaaca745e0b549beac3fb48f0852ea117 100644
--- a/lib/src/checker/resolver.dart
+++ b/lib/src/checker/resolver.dart
@@ -330,7 +330,7 @@ class _VarExtractor extends RecursiveAstVisitor {
/// [LibraryResolverWithInference] above.
///
/// Before inference, this visitor is used to resolve top-levels, classes, and
-/// fields, but nothing withihn method bodies. After inference, this visitor is
+/// fields, but nothing within method bodies. After inference, this visitor is
/// used again to step into method bodies and complete resolution as a second
/// phase.
class RestrictedResolverVisitor extends ResolverVisitor {
@@ -453,6 +453,20 @@ class RestrictedResolverVisitor extends ResolverVisitor {
return super.visitConstructorDeclaration(node);
}
}
+
+ @override
+ visitFieldFormalParameter(FieldFormalParameter node) {
+ // Ensure the field formal parameter's type is updated after inference.
+ // Normally this happens during TypeResolver, but that's before we've done
+ // inference on the field type.
Jennifer Messerly 2015/06/10 18:22:19 Is this running at the right time? In theory, not
Siggi Cherem (dart-lang) 2015/06/10 18:28:30 sgtm. not sure when analyzer does it, but if eleme
+ var element = node.element;
+ if (element is FieldFormalParameterElement) {
+ if (element.type.isDynamic) {
+ element.type = element.field.type;
+ }
+ }
+ super.visitFieldFormalParameter(node);
+ }
}
/// Internal state of the resolver, stored so we can reanalyze portions of the

Powered by Google App Engine
This is Rietveld 408576698