mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] Properly get matching method arguments local classes in static methods
#IDEA-373584 GitOrigin-RevId: 04c8ee6bb7c8427afed171dfdd78b00ab5220a8d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
cd7be3977a
commit
ae47e433b0
+1
-1
@@ -186,7 +186,7 @@ public class JavaLangClassMemberReference extends PsiReferenceBase<PsiLiteralExp
|
||||
private static int matchMethodArguments(PsiMethod method, List<ReflectiveType> argumentTypes) {
|
||||
// Get nested classes because they need to be passed if not static
|
||||
List<PsiClass> enclosingClasses = PsiTreeUtil.collectParents(method, PsiClass.class, false, parent -> {
|
||||
return parent instanceof PsiFile || parent instanceof PsiClass cls && cls.hasModifier(JvmModifier.STATIC);
|
||||
return parent instanceof PsiFile || (parent instanceof PsiModifierListOwner cls && cls.hasModifier(JvmModifier.STATIC));
|
||||
});
|
||||
if (!enclosingClasses.isEmpty()) {
|
||||
// the containing class of the method doesn't need to be passed
|
||||
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
class Constructors {
|
||||
public static void testConstructorInStatic() throws Exception {
|
||||
class X {
|
||||
X(int i) {}
|
||||
class Y {
|
||||
Y() {}
|
||||
Y(String a) {}
|
||||
}
|
||||
}
|
||||
|
||||
X.class.getDeclaredConstructor(int.class);
|
||||
X.Y.class.getDeclaredConstructor(X.class);
|
||||
X.Y.class.getDeclaredConstructor(X.class, String.class);
|
||||
}
|
||||
}
|
||||
+1
@@ -28,6 +28,7 @@ class JavaReflectionMemberAccessTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
fun testConstructorExists() = doTest(true)
|
||||
fun testConstructorInnerClass() = doTest(true)
|
||||
fun testConstructorLocalClass() = doTest(true)
|
||||
fun testConstructorLocalClassInStaticMethod() = doTest(true)
|
||||
|
||||
fun testNewInstance() = doTest(true)
|
||||
fun testBugs() = doTest(true)
|
||||
|
||||
Reference in New Issue
Block a user