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

Unified Diff: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java

Issue 64033002: Version 0.8.10.8 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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: dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java
===================================================================
--- dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java (revision 30037)
+++ dart/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java (working copy)
@@ -244,7 +244,7 @@
promoteTypes(leftOperand);
clearTypePromotionsIfPotentiallyMutatedIn(leftOperand);
clearTypePromotionsIfPotentiallyMutatedIn(rightOperand);
- clearTypePromotionsIfAccessedInScopeAndProtentiallyMutated(rightOperand);
+ clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(rightOperand);
// Visit right operand.
rightOperand.accept(this);
} finally {
@@ -364,7 +364,7 @@
// Type promotion.
promoteTypes(condition);
clearTypePromotionsIfPotentiallyMutatedIn(thenExpression);
- clearTypePromotionsIfAccessedInScopeAndProtentiallyMutated(thenExpression);
+ clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenExpression);
// Visit "then" expression.
thenExpression.accept(this);
} finally {
@@ -572,7 +572,7 @@
// Type promotion.
promoteTypes(condition);
clearTypePromotionsIfPotentiallyMutatedIn(thenStatement);
- clearTypePromotionsIfAccessedInScopeAndProtentiallyMutated(thenStatement);
+ clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(thenStatement);
// Visit "then".
visitStatementInScope(thenStatement);
} finally {
@@ -923,41 +923,6 @@
}
/**
- * If it is appropriate to do so, promotes the current type of the static element associated with
- * the given expression with the given type. Generally speaking, it is appropriate if the given
- * type is more specific than the current type.
- *
- * @param expression the expression used to access the static element whose types might be
- * promoted
- * @param potentialType the potential type of the elements
- */
- protected void promote(Expression expression, Type potentialType) {
- VariableElement element = getPromotionStaticElement(expression);
- if (element != null) {
- // may be mutated somewhere in closure
- if (((VariableElementImpl) element).isPotentiallyMutatedInClosure()) {
- return;
- }
- // prepare current variable type
- Type type = expression.getStaticType();
- // Declared type should not be "dynamic".
- if (type == null || type.isDynamic()) {
- return;
- }
- // Promoted type should not be "dynamic".
- if (potentialType == null || potentialType.isDynamic()) {
- return;
- }
- // Promoted type should be more specific than declared.
- if (!potentialType.isMoreSpecificThan(type)) {
- return;
- }
- // Do promote type of variable.
- promoteManager.setType(element, potentialType);
- }
- }
-
- /**
* Report a conditional analysis error with the given error code and arguments.
*
* @param enclosingElement the enclosing element
@@ -1067,7 +1032,7 @@
* If the variable <i>v</i> is accessed by a closure in <i>s<sub>1</sub></i> then the variable
* <i>v</i> is not potentially mutated anywhere in the scope of <i>v</i>.
*/
- private void clearTypePromotionsIfAccessedInScopeAndProtentiallyMutated(ASTNode target) {
+ private void clearTypePromotionsIfAccessedInClosureAndProtentiallyMutated(ASTNode target) {
for (Element element : promoteManager.getPromotedElements()) {
if (((VariableElementImpl) element).isPotentiallyMutatedInScope()) {
if (isVariableAccessedInClosure(element, target)) {
@@ -1302,6 +1267,44 @@
}
/**
+ * If it is appropriate to do so, promotes the current type of the static element associated with
+ * the given expression with the given type. Generally speaking, it is appropriate if the given
+ * type is more specific than the current type.
+ *
+ * @param expression the expression used to access the static element whose types might be
+ * promoted
+ * @param potentialType the potential type of the elements
+ */
+ private void promote(Expression expression, Type potentialType) {
+ VariableElement element = getPromotionStaticElement(expression);
+ if (element != null) {
+ // may be mutated somewhere in closure
+ if (((VariableElementImpl) element).isPotentiallyMutatedInClosure()) {
+ return;
+ }
+ // prepare current variable type
+ Type type = promoteManager.getType(element);
+ if (type == null) {
+ type = expression.getStaticType();
+ }
+ // Declared type should not be "dynamic".
+ if (type == null || type.isDynamic()) {
+ return;
+ }
+ // Promoted type should not be "dynamic".
+ if (potentialType == null || potentialType.isDynamic()) {
+ return;
+ }
+ // Promoted type should be more specific than declared.
+ if (!potentialType.isMoreSpecificThan(type)) {
+ return;
+ }
+ // Do promote type of variable.
+ promoteManager.setType(element, potentialType);
+ }
+ }
+
+ /**
* Promotes type information using given condition.
*/
private void promoteTypes(Expression condition) {

Powered by Google App Engine
This is Rietveld 408576698