Skip to content

Commit b0ed3e7

Browse files
authored
Get children methods for vararg calls (#483)
* Recursively get methods through getMethodRecursive * fix test * bump ci
1 parent 68965d7 commit b0ed3e7

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

src/org/jetbrains/java/decompiler/modules/decompiler/exps/InvocationExprent.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,9 @@ private boolean isVarArgCall() {
11771177
StructClass cl = DecompilerContext.getStructContext().getClass(classname);
11781178
if (cl != null) {
11791179
StructMethod mt = cl.getMethod(InterpreterUtil.makeUniqueKey(name, stringDescriptor));
1180+
if (mt == null) {
1181+
mt = cl.getMethodRecursive(name, stringDescriptor);
1182+
}
11801183
if (mt != null) {
11811184
return mt.hasModifier(CodeConstants.ACC_VARARGS);
11821185
}

testData/results/pkg/TestVarArgCalls.dec

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,22 @@ public class TestVarArgCalls {
2323
public void printComplex(String fmt, String[]... params) {
2424
System.out.println(String.format(fmt, (Object[])params));// 27
2525
}// 28
26+
27+
public class Parent {
28+
protected void test(TestVarArgCalls.Test... test) {
29+
}// 33
30+
31+
class Child extends TestVarArgCalls.Parent {
32+
public void vararg() {
33+
this.test(TestVarArgCalls.Test.A, TestVarArgCalls.Test.B);// 38
34+
}// 39
35+
}
36+
}
37+
38+
public static enum Test {
39+
A,
40+
B;
41+
}
2642
}
2743

2844
class 'pkg/TestVarArgCalls' {
@@ -160,6 +176,28 @@ class 'pkg/TestVarArgCalls' {
160176
}
161177
}
162178

179+
class 'pkg/TestVarArgCalls$Parent' {
180+
method 'test ([Lpkg/TestVarArgCalls$Test;)V' {
181+
0 28
182+
}
183+
}
184+
185+
class 'pkg/TestVarArgCalls$Parent$Child' {
186+
method 'vararg ()V' {
187+
0 32
188+
7 32
189+
8 32
190+
9 32
191+
d 32
192+
e 32
193+
f 32
194+
11 32
195+
12 32
196+
13 32
197+
14 33
198+
}
199+
}
200+
163201
Lines mapping:
164202
5 <-> 5
165203
6 <-> 6
@@ -178,3 +216,6 @@ Lines mapping:
178216
24 <-> 21
179217
27 <-> 24
180218
28 <-> 25
219+
33 <-> 29
220+
38 <-> 33
221+
39 <-> 34

testData/src/java8/pkg/TestVarArgCalls.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,23 @@ public void printAll(String fmt, String... params) {
2626
public void printComplex(String fmt, String[]... params) {
2727
System.out.println(String.format(fmt, (Object[]) params));
2828
}
29+
30+
public class Parent {
31+
protected void test(Test... test) {
32+
33+
}
34+
35+
class Child extends Parent {
36+
37+
public void vararg() {
38+
test(Test.A, Test.B);
39+
}
40+
41+
}
42+
}
43+
44+
public enum Test {
45+
A,
46+
B
47+
}
2948
}

0 commit comments

Comments
 (0)