Bug 90423

Summary: [1.5][compiler] Generic method overloading. Javac allows but eclipse doesn't
Product: [Eclipse Project] JDT Reporter: Mohan Radhakrishnan <javatech>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED FIXED QA Contact:
Severity: major    
Priority: P3 CC: kent_johnson
Version: 3.1   
Target Milestone: 3.1 M7   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Mohan Radhakrishnan CLA 2005-04-06 06:07:20 EDT
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"
Comment 1 Philipe Mulet CLA 2005-04-06 07:06:15 EDT
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>
Comment 2 Philipe Mulet CLA 2005-04-06 07:20:48 EDT
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
Comment 3 Philipe Mulet CLA 2005-04-06 07:34:38 EDT
*** Bug 90429 has been marked as a duplicate of this bug. ***
Comment 4 Olivier Thomann CLA 2005-05-11 11:31:24 EDT
Verified in I20050510-0010