Closed ihasbini closed 5 years ago
I would like to create a pull request for a fix please. How should I proceed? Thank you.
Merged the corresponding PR (#94) manually.
Please re-test!
Hi @aunkrig ,
We have discovered another regression related to overloaded static imports that the PR #94 didn't fix. I have created a PR #97 with a test describing the issue and a fix attempt.
Let me know if you need more information! Alex
Excellent work... thank you for your PR #97!! Ran all regression tests, work like a breeze.
The fix is on the TRUNK - do you want me to prepare a new release?
Yes please, a quick release would be neat! It would allow us to catch-up (we are stuck on 3.0.12).
Version 3.0.15 just came out - please test and close.
It works perfectly @aunkrig , thanks! (I can't close it though, I didn't create it in the first place).
Good to hear. Thanks for your support!
When a class "on-demand" imports static methods from other class(es), and when the methods have the same name, and different parameter types, then the exception "org.codehaus.commons.compiler.CompileException: Ambiguous static method import" is thrown.
The below code in UnitCompiler.java does not select the "most specific method" to bind to the invocation: ` // Static method declared through static-import-on-demand? for (Object o : this.importStaticOnDemand(mi.methodName)) {
`
To reproduce: ` public class C1 { public static String testOverload(int param) { return "Hello World (int): " + param; } }
public class C2 { public static String testOverload(long param) { return "Hello World (long): " + param; } public static String testOverload(short param) { return "Hello World (short): " + param; } }
import static test.C1.; import static test.C2.;
public class StaticImports { public void execute() { System.out.println(testOverload((short) 1)); System.out.println(testOverload((long) 2)); System.out.println(testOverload((int) 3)); } } `