Skip to content

Commit e7fe549

Browse files
authored
Fix calling a method with number varargs (#464)
1 parent 643008a commit e7fe549

File tree

3 files changed

+247
-197
lines changed

3 files changed

+247
-197
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,6 +1421,16 @@ private BitSet getAmbiguousParameters(List<StructMethod> matches) {
14211421
((FunctionExprent) exp).setNeedsCast(true);
14221422
}
14231423

1424+
if (i == md.params.length - 1 && mt.hasModifier(CodeConstants.ACC_VARARGS)) {
1425+
if (exp instanceof NewExprent newE && newE.getExprType().arrayDim > 0) {
1426+
for (Exprent entry : newE.getLstArrayElements()) {
1427+
if (entry instanceof FunctionExprent func && func.getSimpleCastType() != null) {
1428+
func.setNeedsCast(true);
1429+
}
1430+
}
1431+
}
1432+
}
1433+
14241434
// Check if the current parameters and method descriptor are of the same type, or if the descriptor's type is a superset of the parameter's type.
14251435
// This check ensures that parameters that can be safely passed don't have an unneeded cast on them, such as System.out.println((int)5);.
14261436
// TODO: The root cause of the above issue seems to be threading related- When debugging line by line it doesn't cast, but when running normally it does. More digging needs to be done to figure out why this happens.

0 commit comments

Comments
 (0)