mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
retrieve expected type by containing array creation expression (IDEA-132794)
This commit is contained in:
@@ -215,6 +215,15 @@ public class PsiTypesUtil {
|
||||
}
|
||||
else if (PsiUtil.isCondition(methodCall, parent)) {
|
||||
return PsiType.BOOLEAN.getBoxedType(parent);
|
||||
}
|
||||
else if (parent instanceof PsiArrayInitializerExpression) {
|
||||
final PsiElement gParent = parent.getParent();
|
||||
if (gParent instanceof PsiNewExpression) {
|
||||
final PsiType type = ((PsiNewExpression)gParent).getType();
|
||||
if (type instanceof PsiArrayType) {
|
||||
return ((PsiArrayType)type).getComponentType();
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
class Test {
|
||||
public <T> T f() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object foo() {
|
||||
return true ? new String[]{f()} : new String[][]{f()};
|
||||
}
|
||||
}
|
||||
@@ -434,6 +434,10 @@ public class GenericsHighlightingTest extends LightDaemonAnalyzerTestCase {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testExpectedTypeFromOuterArrayCreation() throws Exception {
|
||||
doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false);
|
||||
}
|
||||
|
||||
public void testJavaUtilCollections_NoVerify() throws Exception {
|
||||
PsiClass collectionsClass = getJavaFacade().findClass("java.util.Collections", GlobalSearchScope.moduleWithLibrariesScope(getModule()));
|
||||
assertNotNull(collectionsClass);
|
||||
|
||||
Reference in New Issue
Block a user