Community
Participate
Working Groups
public class Overloading { public static <S extends String> S foo() { System.out.println("String"); return null; } public static <N extends Number> N foo() { System.out.println("Number"); return null; } public static void main(String[] args) { Overloading.<String>foo(); Overloading.<Number>foo(); Overloading o = new Overloading(); o.<Number>foo(); } } This class compiles and works when you use javac but eclipse3.1M5a shows an error "Duplicate method foo() in type Overloading"
Added MethodVerifyTest#test050. Changed SourceTypeBinding#methods() to better detect collisions (check on return type only occurs when compliance 1.5 is enabled), the logic was wrong. Still the method lookup then gets confused, since it picks the wrong message invocation. 1. ERROR in X.java (at line 14) Overloading.<String>foo(); ^^^ Bound mismatch: The generic method foo() of type X is not applicable for the arguments () since the type String is not a valid substitute for the bounded parameter <N extends Number>
Tuned findExactMatch to only answer valid method binding when dealing with generic methods since better matches can exist and could be found by non exact match. Fixed Kent - pls verify changes
*** Bug 90429 has been marked as a duplicate of this bug. ***
Verified in I20050510-0010