mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: fix AIOOBE (EA-131665)
This commit is contained in:
+4
-3
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2017 Dave Griffith, Bas Leijdekkers
|
||||
* Copyright 2003-2018 Dave Griffith, Bas Leijdekkers
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -414,7 +414,7 @@ public class MethodCallUtils {
|
||||
|
||||
public static boolean isUsedAsSuperConstructorCallArgument(@NotNull PsiParameter parameter, boolean superMustBeLibrary) {
|
||||
final PsiElement scope = parameter.getDeclarationScope();
|
||||
if (!(scope instanceof PsiMethod)) {
|
||||
if (!(scope instanceof PsiMethod) || !((PsiMethod)scope).isConstructor()) {
|
||||
return false;
|
||||
}
|
||||
PsiMethod method = (PsiMethod)scope;
|
||||
@@ -445,7 +445,8 @@ public class MethodCallUtils {
|
||||
if (JavaPsiConstructorUtil.isSuperConstructorCall(call) && (!superMustBeLibrary || method instanceof PsiCompiledElement)) {
|
||||
return true;
|
||||
}
|
||||
parameter = method.getParameterList().getParameters()[index];
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
parameter = parameters[Math.min(index, parameters.length - 1)];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+11
@@ -44,6 +44,17 @@ public class BooleanParameterInspectionTest extends LightInspectionTestCase {
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testVarargs() {
|
||||
doTest("class Y {" +
|
||||
" public Y(boolean... b) {}" +
|
||||
"}" +
|
||||
"class X extends Y {" +
|
||||
" public /*'public' constructor 'X()' with 'boolean' parameter*/X/**/(boolean b) {" +
|
||||
" super(true, b);" +
|
||||
" }" +
|
||||
"}");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LocalInspectionTool getInspection() {
|
||||
return new BooleanParameterInspection();
|
||||
|
||||
Reference in New Issue
Block a user