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

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

Issue 38353003: Issue 13807. Support for function types promotion. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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
Index: editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java
diff --git a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java
index f998bcd8a84cbc2288ba3bf3cdcea85b9bb5cdbb..b1bb4729f45a427bc44793022cff23a3be13a330 100644
--- a/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java
+++ b/editor/tools/plugins/com.google.dart.engine/src/com/google/dart/engine/internal/resolver/ResolverVisitor.java
@@ -912,34 +912,22 @@ public class ResolverVisitor extends ScopedVisitor {
protected void promote(Expression expression, Type potentialType) {
VariableElement element = getPromotionStaticElement(expression);
if (element != null) {
- promote(element, potentialType);
- }
- }
-
- /**
- * If it is appropriate to do so, promotes the current type of the given element with the given
- * type. Generally speaking, it is appropriate if the given type is more specific than the current
- * type.
- *
- * @param element the element whose type might be promoted
- * @param potentialType the potential type of the element
- */
- protected void promote(VariableElement element, Type potentialType) {
- // Declared type should not be "dynamic".
- Type type = element.getType();
- 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;
+ 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);
}
- // Do promote type of variable.
- promoteManager.setType(element, potentialType);
}
/**

Powered by Google App Engine
This is Rietveld 408576698