mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-124950 Good code is red: Reference to array class is not detected correctly
This commit is contained in:
+2
-24
@@ -71,9 +71,9 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
|
||||
// return not null in case of String[], int[], double[][]
|
||||
@Nullable
|
||||
private PsiType inferArrayType() {
|
||||
PsiType arrayTypeBase = getClassReferenceFromExpression(this.getInvokedExpression());
|
||||
PsiType arrayTypeBase = getClassReferenceFromExpression(this);
|
||||
if (arrayTypeBase == null) return null;
|
||||
return TypesUtil.createJavaLangClassType(arrayTypeBase.createArrayType(), this.getProject(), this.getResolveScope());
|
||||
return TypesUtil.createJavaLangClassType(arrayTypeBase, this.getProject(), this.getResolveScope());
|
||||
}
|
||||
|
||||
private PsiType inferType(@Nullable Boolean isSetter) {
|
||||
@@ -97,28 +97,6 @@ public class GrIndexPropertyImpl extends GrExpressionImpl implements GrIndexProp
|
||||
final PsiManager manager = getManager();
|
||||
final GlobalSearchScope resolveScope = getResolveScope();
|
||||
|
||||
if (argTypes.length == 0) {
|
||||
PsiType arrType = null;
|
||||
if (selected instanceof GrBuiltinTypeClassExpression) {
|
||||
arrType = ((GrBuiltinTypeClassExpression)selected).getPrimitiveType();
|
||||
}
|
||||
|
||||
if (selected instanceof GrReferenceExpression) {
|
||||
final PsiElement resolved = ((GrReferenceExpression)selected).resolve();
|
||||
if (resolved instanceof PsiClass) {
|
||||
String qname = ((PsiClass)resolved).getQualifiedName();
|
||||
if (qname != null) {
|
||||
arrType = TypesUtil.createTypeByFQClassName(qname, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arrType != null) {
|
||||
final PsiArrayType param = arrType.createArrayType();
|
||||
return TypesUtil.createJavaLangClassType(param, getProject(), resolveScope);
|
||||
}
|
||||
}
|
||||
|
||||
if (PsiImplUtil.isSimpleArrayAccess(thisType, argTypes, this, isSetter != null ? isSetter.booleanValue() : PsiUtil.isLValue(this))) {
|
||||
return TypesUtil.boxPrimitiveType(((PsiArrayType)thisType).getComponentType(), manager, resolveScope);
|
||||
}
|
||||
|
||||
+1
-1
@@ -1069,8 +1069,8 @@ public class ResolveUtil {
|
||||
}
|
||||
|
||||
if (expression instanceof GrIndexProperty) {
|
||||
if (((GrIndexProperty)expression).getExpressionArguments().length != 0) return null;
|
||||
PsiType arrayTypeBase = getClassReferenceFromExpression(((GrIndexProperty)expression).getInvokedExpression());
|
||||
|
||||
return arrayTypeBase == null ? null : arrayTypeBase.createArrayType();
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -713,6 +713,13 @@ def foo(List list) {
|
||||
doExprTest 'double[][][].class', 'java.lang.Class<double[][][]>'
|
||||
}
|
||||
|
||||
void testClassExpressionsWithArguments() {
|
||||
doExprTest 'String[1]', 'java.lang.Object'
|
||||
doExprTest 'String[1][]', 'java.lang.Object'
|
||||
doExprTest 'String[1][].class', 'java.lang.Class<java.lang.Object>'
|
||||
doExprTest 'int[][1].class', 'java.lang.Class<java.lang.Object>'
|
||||
}
|
||||
|
||||
void 'test list literal type'() {
|
||||
doExprTest '[]', 'java.util.List'
|
||||
doExprTest '[null]', 'java.util.List'
|
||||
|
||||
Reference in New Issue
Block a user