Community
Participate
Working Groups
In the given testcase, ######### public class X<T> { T field1; public X(T param) { field1 = param; } public static void testFunction(String param){ System.out.println(1); } public static void testFunction(Object Param) { System.out.println(2); } public T getField() { return field1; } public static void main(String[] args) { X.testFunction(new X<>("hello").getField()); } } ######## Search for testFunction(String Param) doesn't return anything. However, search for testFunction(Object Param) does return the call from main, which is clearly wrong.
This seems to be a problem with the compiler, probably not yet implemented. The test is actually test007 of GenericsRegressionTest_1_7. The call is getting binded to testFunction(Object) causing the unexpected behavior. Srikanth, can you please confirm if this is yet to be done.
(In reply to comment #1) > This seems to be a problem with the compiler, probably not yet implemented. The [...] > Srikanth, can you please confirm if this is yet to be done. Yes, this is one of the open issues still being worked on. I think the fix in the compiler will likely automatically resolve this issue. We can wait for bug 339478 to be resolved to retest. (In reply to comment #0) [...] > Search for testFunction(String Param) doesn't return anything. However, search > for testFunction(Object Param) does return the call from main, which is clearly > wrong. I have to violently disagree. It _is_ wrong, but not clearly wrong :) The leap from inferring the unspecified type argument to be Object to String instead requires the application of a page long worth of dreadfully dense, highly pedantic veribiage, (reminds me of the Arthur Eddington's repartee around understanding relativity theory) is by no means clear.
(In reply to comment #2) > Yes, this is one of the open issues still being worked on. I think the > fix in the compiler will likely automatically resolve this issue. We can > wait for bug 339478 to be resolved to retest. Yes, the latest patch for bug 339478 fixes this automatically. Once that patch is released, this bug can be closed with a regression test.
Created attachment 195823 [details] Patch for the test Thanks Srikanth for the patch for the test.
Fix for bug 339478 has fixed the problem. Released the test for this scenario.
Verified using patch feature 1.0.0-20110623-0900