Community
Participate
Working Groups
3.5M3 Hovering on #bar(...) invocation on line (5) should not show "<Object> Object bar(Object)" instead of "<String> String bar(String)". The compiler does the right thing, but codeselect seems to ignore the presence of the "(String)" cast in front of selected expression; which leads to generic inference considering expected type (String). import java.util.List; public class X { void foo(boolean b, Runnable r) { Zork z = null; String s = (String) bar(z); // 5 } <T> T bar(T t) { return t; } }
The problem is that the SelectionEngine currently build an AST without the cast expression import java.util.List; public class X { public X() { } void foo(boolean b, Runnable r) { Zork z; String s = <SelectOnMessageSend:bar(z)>; } <T>T bar(T t) { } }
Changing Version tag to something more believable.
Actually, my original description was wrong. No inference using type expectation (15.12.2.8) should occur with a cast. So hover should indicate "<Object> Object bar(Object)". Now if the cast is removed, it should surface "<String> String bar(String)" as expected type is considered for inference (15.12.2.8).
Created attachment 140105 [details] Proposed fix
Released for 3.6M1 Tests added GenericsSelectionTest#test0024() ResolveTests_1_5#test0123() Test updated SelectionTest#test19()
verified for 3.6M1 using build I20090802-2000