retrieve collection type from capture in foreach stmt (IDEA-151406)

This commit is contained in:
Anna Kozlova
2016-02-09 12:41:01 +01:00
parent e192fa8c4c
commit 5793ec77ed
3 changed files with 16 additions and 0 deletions
@@ -297,6 +297,9 @@ public class JavaGenericsUtil {
}
}
}
if (type instanceof PsiCapturedWildcardType) {
return getCollectionItemType(((PsiCapturedWildcardType)type).getUpperBound(), scope);
}
return null;
}
@@ -0,0 +1,9 @@
import java.util.Collection;
import java.util.Map;
class Test {
private void foo(Map.Entry<Integer, ? extends Collection<String>> entry) {
for (String propertyName : entry.getValue()) {}
}
}
@@ -958,4 +958,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
public void testRetrieveInferenceErrorsFromContainingCallsIfCurrentDoesNotProvideAny() throws Exception {
doTest();
}
public void testForeachOverCapturedWildcardWithCollectionUpperBound() throws Exception {
doTest();
}
}