redundant cast: ignore foreach iter values with functional expressions inside casts (IDEA-126641)

This commit is contained in:
Anna Kozlova
2014-06-27 18:31:54 +02:00
parent 3e9eae3b52
commit 5b91d6550e
4 changed files with 16 additions and 2 deletions
@@ -518,7 +518,9 @@ public class RedundantCastUtil {
return;
}
}
}
}
} else {
return;
}
}
if (parent instanceof PsiThrowStatement) {
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<problems/>
@@ -0,0 +1,10 @@
import java.util.Arrays;
import java.util.Iterator;
class IterableMain {
public static void main(final String... args) {
for (final String s : (Iterable<String>) XIterator::new) {}
}
public static interface XIterator extends Iterator<String> {}
}
@@ -18,7 +18,6 @@ package com.intellij.codeInspection;
import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
import com.intellij.codeInspection.redundantCast.RedundantCastInspection;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.testFramework.IdeaTestUtil;
@@ -33,6 +32,7 @@ public class RedundantCast18Test extends InspectionTestCase {
public void testLambdaContext() throws Exception { doTest(); }
public void testMethodRefContext() throws Exception { doTest(); }
public void testExpectedSupertype() throws Exception { doTest(); }
public void testForeachValue() throws Exception { doTest(); }
@Override
protected Sdk getTestProjectSdk() {