Bug 90423 - [1.5][compiler] Generic method overloading. Javac allows but eclipse doesn't
Summary: [1.5][compiler] Generic method overloading. Javac allows but eclipse doesn't
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 90429 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-04-06 06:07 EDT by Mohan Radhakrishnan CLA
Modified: 2005-05-11 11:31 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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