mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
detect array initializer type based on short variable array notation (IDEA-147881)
This commit is contained in:
@@ -218,6 +218,12 @@ public class PsiTypesUtil {
|
||||
return ((PsiArrayType)type).getComponentType();
|
||||
}
|
||||
}
|
||||
else if (gParent instanceof PsiVariable) {
|
||||
final PsiType type = ((PsiVariable)gParent).getType();
|
||||
if (type instanceof PsiArrayType) {
|
||||
return ((PsiArrayType)type).getComponentType();
|
||||
}
|
||||
}
|
||||
else if (gParent instanceof PsiArrayInitializerExpression) {
|
||||
final PsiType expectedTypeByParent = getExpectedTypeByParent((PsiExpression)parent);
|
||||
return expectedTypeByParent != null && expectedTypeByParent instanceof PsiArrayType
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
class Test {
|
||||
{
|
||||
Object x = null;
|
||||
Object[] objs = {x == null ? "N/A" : x};
|
||||
}
|
||||
}
|
||||
+4
@@ -877,4 +877,8 @@ public class GenericsHighlighting8Test extends LightDaemonAnalyzerTestCase {
|
||||
public void testUncheckedWarningsWhenInferredTypeLeadsToRawRoGenericAssignment() throws Exception {
|
||||
doTest(true);
|
||||
}
|
||||
|
||||
public void testExpectedTypeBasedOnArrayCreationWithoutExplicitType() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user