mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
accept intersection types in foreach stmts (IDEA-125800)
This commit is contained in:
@@ -286,6 +286,14 @@ public class JavaGenericsUtil {
|
||||
PsiType itemType = superClassSubstitutor.substitute(typeParameter);
|
||||
return itemType == null ? PsiType.getJavaLangObject(manager, aClass.getResolveScope()) : itemType;
|
||||
}
|
||||
if (type instanceof PsiIntersectionType) {
|
||||
for (PsiType conjunct : ((PsiIntersectionType)type).getConjuncts()) {
|
||||
final PsiType itemType = getCollectionItemType(conjunct, scope);
|
||||
if (itemType != null) {
|
||||
return itemType;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import java.util.List;
|
||||
|
||||
abstract class Test {
|
||||
abstract <T extends List<String> & Runnable> T list();
|
||||
|
||||
public void test()
|
||||
{
|
||||
for (String s : list()) {}
|
||||
}
|
||||
}
|
||||
@@ -364,6 +364,7 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
public void testIDEA119757() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA67578() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA57388() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
public void testIDEA125800() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
|
||||
//jdk should propagate LL 1.4 but actually it provides LL 1.7?!
|
||||
public void testCastObjectToIntJdk14() { doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_4, false); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user