Open yawkat opened 3 years ago
@yawkat I like the idea with a flag like ALLOW_OMIT_VARARG
which is added if there is no method with the same name and args count minus one (similar to MethodInfo.isOverloadedBy
). Good place to add that flag is here. This will cover most cases.
For complete fix, we need to directly modify insn (remove that arg) in MethodInvokeVisitor
and run overload method processing for that modified method. In latter case flag is not needed, but implementation is more complex.
Calls to vararg functions with an empty array parameter are not sugared as a varargs call because they are a
NEW_ARRAY
with a zero literal as the arg instead of aFILLED_NEW_ARRAY
. This can be fixed easily:However, the issue with this approach is that it leads to ambiguity with overloaded methods. When
test()
andtest(int... a)
exist, thenew int[0]
would have to be retained. This appears to be an issue with all vararg decompilation right now, but I'm still vary of submitting what is technically a regression before the overload issue is fixed. Unfortunately vararg sugaring happens after overload resolution, making this a bit difficult. One idea is adding an AFlag that preemptively marks any invocations with possible non-vararg conflicts and disabling vararg sugaring for those methods altogether, but this is fairly conservative.Test case: