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

Unified Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1428803004: Revert "Compute propagated type for final instance fields (partially addresses issue 23001)" (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/resolver.dart
diff --git a/pkg/analyzer/lib/src/generated/resolver.dart b/pkg/analyzer/lib/src/generated/resolver.dart
index 2808c6648e4cb05f0a4f8b158dbbc995e51a42fd..9bd7788b3cbf54886f7ce375d93abbfcd9c96d2e 100644
--- a/pkg/analyzer/lib/src/generated/resolver.dart
+++ b/pkg/analyzer/lib/src/generated/resolver.dart
@@ -10902,27 +10902,6 @@ class ResolverVisitor extends ScopedVisitor {
}
@override
- void visitClassMembersInScope(ClassDeclaration node) {
- safelyVisit(node.documentationComment);
- node.metadata.accept(this);
- //
- // Visit the fields before other members so that instance fields will have
- // propagated types associated with them before we see their use sites.
- //
- List<ClassMember> nonFields = <ClassMember>[];
- for (ClassMember member in node.members) {
- if (member is FieldDeclaration) {
- member.accept(this);
- } else {
- nonFields.add(member);
- }
- }
- for (ClassMember member in nonFields) {
- member.accept(this);
- }
- }
-
- @override
Object visitComment(Comment node) {
if (node.parent is FunctionDeclaration ||
node.parent is ConstructorDeclaration ||
@@ -11534,30 +11513,9 @@ class ResolverVisitor extends ScopedVisitor {
Object visitVariableDeclaration(VariableDeclaration node) {
super.visitVariableDeclaration(node);
VariableElement element = node.element;
- FunctionElement initializerElement = element.initializer;
- Expression initializer = node.initializer;
- if (initializerElement is FunctionElementImpl && initializer != null) {
- initializerElement.returnType = initializer.staticType;
- }
- //
- // Propagate types for instance fields. Top-level variables and static
- // fields are handled elsewhere.
- //
- // TODO(brianwilkerson) Instance field propagation should probably be moved
- // into the class InstanceMemberInferrer because we're already doing
- // something there for strong mode.
- //
- if (initializer != null &&
- element is FieldElementImpl &&
- !element.isStatic &&
- element.isFinal) {
- DartType staticType = element.type;
- DartType bestType = initializer.bestType;
- if (bestType != null &&
- bestType != staticType &&
- bestType.isMoreSpecificThan(staticType)) {
- element.propagatedType = bestType;
- }
+ if (element.initializer != null && node.initializer != null) {
+ (element.initializer as FunctionElementImpl).returnType =
+ node.initializer.staticType;
}
// Note: in addition to cloning the initializers for const variables, we
// have to clone the initializers for non-static final fields (because if
@@ -11567,9 +11525,9 @@ class ResolverVisitor extends ScopedVisitor {
(element is FieldElement &&
element.isFinal &&
!element.isStatic)) &&
- initializer != null) {
+ node.initializer != null) {
(element as ConstVariableElement).constantInitializer =
- new ConstantAstCloner().cloneNode(initializer);
+ new ConstantAstCloner().cloneNode(node.initializer);
}
return null;
}
« no previous file with comments | « no previous file | pkg/analyzer/test/generated/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698