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

Unified Diff: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java

Issue 11419186: Allow not only 'Iterator iterator()' but also 'Iterator iterator' (field). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
diff --git a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
index ea351cac8b70fb846de97f6cbe34821ef1286ff1..c6fc65acb3a2d7214ed7608e51e655fb504fff79 100644
--- a/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
+++ b/compiler/java/com/google/dart/compiler/type/TypeAnalyzer.java
@@ -1785,9 +1785,15 @@ public class TypeAnalyzer implements DartCompilationPhase {
Member iteratorMember = lookupMember(iterableType, "iterator", iterableExpression);
Type elementType = null;
if (iteratorMember != null) {
+ Type memberReturnType = null;
if (TypeKind.of(iteratorMember.getType()) == TypeKind.FUNCTION) {
FunctionType iteratorMethod = (FunctionType) iteratorMember.getType();
- InterfaceType asInstanceOf = types.asInstanceOf(iteratorMethod.getReturnType(),
+ memberReturnType = iteratorMethod.getReturnType();
+ } else if (ElementKind.of(iteratorMember.getElement()) == ElementKind.FIELD) {
+ memberReturnType = iteratorMember.getType();
+ }
+ if (memberReturnType != null) {
+ InterfaceType asInstanceOf = types.asInstanceOf(memberReturnType,
dynamicIteratorType.getElement());
if (asInstanceOf != null) {
elementType = asInstanceOf.getArguments().get(0);
@@ -1795,8 +1801,7 @@ public class TypeAnalyzer implements DartCompilationPhase {
} else {
InterfaceType expectedIteratorType = dynamicIteratorType.subst(
Arrays.asList(variableType), dynamicIteratorType.getElement().getTypeParameters());
- typeError(iterableExpression,
- TypeErrorCode.FOR_IN_WITH_INVALID_ITERATOR_RETURN_TYPE,
+ typeError(iterableExpression, TypeErrorCode.FOR_IN_WITH_INVALID_ITERATOR_RETURN_TYPE,
expectedIteratorType);
}
} else {
« no previous file with comments | « no previous file | compiler/javatests/com/google/dart/compiler/type/TypeAnalyzerCompilerTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698