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

Side by Side Diff: pkg/analyzer/lib/src/generated/resolver.dart

Issue 1327363002: Fixed the last unit test that was failing with the new task model (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine.resolver; 5 library engine.resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'ast.dart'; 9 import 'ast.dart';
10 import 'constant.dart'; 10 import 'constant.dart';
(...skipping 9548 matching lines...) Expand 10 before | Expand all | Expand 10 after
9559 9559
9560 /** 9560 /**
9561 * The static variables that have an initializer. These are the variables that 9561 * The static variables that have an initializer. These are the variables that
9562 * need to be re-resolved after static variables have their types inferred. A 9562 * need to be re-resolved after static variables have their types inferred. A
9563 * subset of these variables are those whose types should be inferred. The 9563 * subset of these variables are those whose types should be inferred. The
9564 * list will be empty unless the resolver is being run in strong mode. 9564 * list will be empty unless the resolver is being run in strong mode.
9565 */ 9565 */
9566 final List<VariableElement> staticVariables = <VariableElement>[]; 9566 final List<VariableElement> staticVariables = <VariableElement>[];
9567 9567
9568 /** 9568 /**
9569 * A flag indicating whether we are currently visiting a child of either a
9570 * field or a top-level variable.
9571 */
9572 bool inFieldOrTopLevelVariable = false;
9573
9574 /**
9569 * A flag indicating whether we should discard errors while resolving the 9575 * A flag indicating whether we should discard errors while resolving the
9570 * initializer for variable declarations. We do this for top-level variables 9576 * initializer for variable declarations. We do this for top-level variables
9571 * and fields because their initializer will be re-resolved at a later time. 9577 * and fields because their initializer will be re-resolved at a later time.
9572 */ 9578 */
9573 bool discardErrorsInInitializer = false; 9579 bool discardErrorsInInitializer = false;
9574 9580
9575 /** 9581 /**
9576 * Initialize a newly created visitor to resolve the nodes in an AST node. 9582 * Initialize a newly created visitor to resolve the nodes in an AST node.
9577 * 9583 *
9578 * The [definingLibrary] is the element for the library containing the node 9584 * The [definingLibrary] is the element for the library containing the node
(...skipping 14 matching lines...) Expand all
9593 TypeProvider typeProvider, AnalysisErrorListener errorListener, 9599 TypeProvider typeProvider, AnalysisErrorListener errorListener,
9594 {Scope nameScope, 9600 {Scope nameScope,
9595 InheritanceManager inheritanceManager, 9601 InheritanceManager inheritanceManager,
9596 StaticTypeAnalyzerFactory typeAnalyzerFactory}) 9602 StaticTypeAnalyzerFactory typeAnalyzerFactory})
9597 : strongMode = definingLibrary.context.analysisOptions.strongMode, 9603 : strongMode = definingLibrary.context.analysisOptions.strongMode,
9598 super(definingLibrary, source, typeProvider, 9604 super(definingLibrary, source, typeProvider,
9599 new DisablableErrorListener(errorListener)); 9605 new DisablableErrorListener(errorListener));
9600 9606
9601 @override 9607 @override
9602 Object visitBlockFunctionBody(BlockFunctionBody node) { 9608 Object visitBlockFunctionBody(BlockFunctionBody node) {
9609 if (inFieldOrTopLevelVariable) {
9610 return super.visitBlockFunctionBody(node);
9611 }
9603 return null; 9612 return null;
9604 } 9613 }
9605 9614
9606 @override 9615 @override
9607 Object visitExpressionFunctionBody(ExpressionFunctionBody node) { 9616 Object visitExpressionFunctionBody(ExpressionFunctionBody node) {
9617 if (inFieldOrTopLevelVariable) {
9618 return super.visitExpressionFunctionBody(node);
9619 }
9608 return null; 9620 return null;
9609 } 9621 }
9610 9622
9611 @override 9623 @override
9612 Object visitFieldDeclaration(FieldDeclaration node) { 9624 Object visitFieldDeclaration(FieldDeclaration node) {
9613 if (strongMode && node.isStatic) { 9625 bool wasInFieldOrTopLevelVariable = inFieldOrTopLevelVariable;
9614 _addStaticVariables(node.fields.variables); 9626 try {
9615 bool wasDiscarding = discardErrorsInInitializer; 9627 inFieldOrTopLevelVariable = true;
9616 discardErrorsInInitializer = true; 9628 if (strongMode && node.isStatic) {
9617 try { 9629 _addStaticVariables(node.fields.variables);
9618 return super.visitFieldDeclaration(node); 9630 bool wasDiscarding = discardErrorsInInitializer;
9619 } finally { 9631 discardErrorsInInitializer = true;
9620 discardErrorsInInitializer = wasDiscarding; 9632 try {
9633 return super.visitFieldDeclaration(node);
9634 } finally {
9635 discardErrorsInInitializer = wasDiscarding;
9636 }
9621 } 9637 }
9638 return super.visitFieldDeclaration(node);
9639 } finally {
9640 inFieldOrTopLevelVariable = wasInFieldOrTopLevelVariable;
9622 } 9641 }
9623 return super.visitFieldDeclaration(node);
9624 } 9642 }
9625 9643
9626 @override 9644 @override
9627 Object visitNode(AstNode node) { 9645 Object visitNode(AstNode node) {
9628 if (discardErrorsInInitializer) { 9646 if (discardErrorsInInitializer) {
9629 AstNode parent = node.parent; 9647 AstNode parent = node.parent;
9630 if (parent is VariableDeclaration && parent.initializer == node) { 9648 if (parent is VariableDeclaration && parent.initializer == node) {
9631 DisablableErrorListener listener = errorListener; 9649 DisablableErrorListener listener = errorListener;
9632 return listener.disableWhile(() => super.visitNode(node)); 9650 return listener.disableWhile(() => super.visitNode(node));
9633 } 9651 }
9634 } 9652 }
9635 return super.visitNode(node); 9653 return super.visitNode(node);
9636 } 9654 }
9637 9655
9638 @override 9656 @override
9639 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 9657 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
9640 if (strongMode) { 9658 bool wasInFieldOrTopLevelVariable = inFieldOrTopLevelVariable;
9641 _addStaticVariables(node.variables.variables); 9659 try {
9642 bool wasDiscarding = discardErrorsInInitializer; 9660 inFieldOrTopLevelVariable = true;
9643 discardErrorsInInitializer = true; 9661 if (strongMode) {
9644 try { 9662 _addStaticVariables(node.variables.variables);
9645 return super.visitTopLevelVariableDeclaration(node); 9663 bool wasDiscarding = discardErrorsInInitializer;
9646 } finally { 9664 discardErrorsInInitializer = true;
9647 discardErrorsInInitializer = wasDiscarding; 9665 try {
9666 return super.visitTopLevelVariableDeclaration(node);
9667 } finally {
9668 discardErrorsInInitializer = wasDiscarding;
9669 }
9648 } 9670 }
9671 return super.visitTopLevelVariableDeclaration(node);
9672 } finally {
9673 inFieldOrTopLevelVariable = wasInFieldOrTopLevelVariable;
9649 } 9674 }
9650 return super.visitTopLevelVariableDeclaration(node);
9651 } 9675 }
9652 9676
9653 /** 9677 /**
9654 * Add all of the [variables] with initializers to the list of variables whose 9678 * Add all of the [variables] with initializers to the list of variables whose
9655 * type can be inferred. Technically, we only infer the types of variables 9679 * type can be inferred. Technically, we only infer the types of variables
9656 * that do not have a static type, but all variables with initializers 9680 * that do not have a static type, but all variables with initializers
9657 * potentially need to be re-resolved after inference because they might 9681 * potentially need to be re-resolved after inference because they might
9658 * refer to a field whose type was inferred. 9682 * refer to a field whose type was inferred.
9659 */ 9683 */
9660 void _addStaticVariables(NodeList<VariableDeclaration> variables) { 9684 void _addStaticVariables(NodeList<VariableDeclaration> variables) {
(...skipping 5877 matching lines...) Expand 10 before | Expand all | Expand 10 after
15538 nonFields.add(node); 15562 nonFields.add(node);
15539 return null; 15563 return null;
15540 } 15564 }
15541 15565
15542 @override 15566 @override
15543 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this); 15567 Object visitNode(AstNode node) => node.accept(TypeResolverVisitor_this);
15544 15568
15545 @override 15569 @override
15546 Object visitWithClause(WithClause node) => null; 15570 Object visitWithClause(WithClause node) => null;
15547 } 15571 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698