mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
NPE & SOE on array access converting
This commit is contained in:
@@ -448,9 +448,10 @@ public class PsiImplUtil {
|
||||
TypesUtil.isAssignable(PsiType.INT, argTypes[0], manager, resolveScope);
|
||||
}
|
||||
|
||||
public static GroovyResolveResult getIndexPropertyMethodCandidate(PsiType thisType,
|
||||
public static GroovyResolveResult getIndexPropertyMethodCandidate(@Nullable PsiType thisType,
|
||||
PsiType[] argTypes,
|
||||
GroovyPsiElement place) {
|
||||
if (thisType == null) return GroovyResolveResult.EMPTY_RESULT;
|
||||
GroovyResolveResult[] candidates = ResolveUtil.getMethodCandidates(thisType, "getAt", place, argTypes);
|
||||
if (candidates.length != 1) {
|
||||
final GrTupleType tupleType = new GrTupleType(argTypes, JavaPsiFacade.getInstance(place.getProject()), place.getResolveScope());
|
||||
|
||||
+1
-1
@@ -758,7 +758,7 @@ public class ExpressionGenerator extends Generator {
|
||||
final GrNamedArgument[] namedArgs = argList.getNamedArguments();
|
||||
|
||||
if (PsiImplUtil.isSimpleArrayAccess(thisType, argTypes, manager, resolveScope)) {
|
||||
expression.accept(this);
|
||||
selectedExpression.accept(this);
|
||||
builder.append("[");
|
||||
final GrExpression arg = exprArgs[0];
|
||||
arg.accept(this);
|
||||
|
||||
+3
@@ -150,4 +150,7 @@ public final class Matcher {
|
||||
void testAnonymousFromMap() {doTest()}
|
||||
void testClosure() {doTest()}
|
||||
void _testListAsArray() {doTest()}
|
||||
|
||||
void testUnresolvedArrayAccess() {doTest()}
|
||||
void testArrayAccess() {doTest()}
|
||||
}
|
||||
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
int[] foo = [1, 2, 3]
|
||||
print foo[2]
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
java.lang.Integer[] foo = new java.lang.Integer[]{1, 2, 3};
|
||||
print(foo[2]);
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
def foo
|
||||
print(foo[1])
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
java.lang.Object foo;
|
||||
print(foo.getAt(1));
|
||||
Reference in New Issue
Block a user