Bug 71241 - [1.5] different methods with same erasure should not override
Summary: [1.5] different methods with same erasure should not override
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M1   Edit
Assignee: Kent Johnson CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-02 12:04 EDT by Markus Keller CLA
Modified: 2005-01-11 11:02 EST (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 Markus Keller CLA 2004-08-02 12:04:00 EDT
200406251208 + jdt from 20040801:

In the following example, B#useList() does not override A#useList, since the
argument types don't match:

class A {
	List<String> useList(List<String> la) {
		la.add("asdf");
		return la;
	}
}

class B extends A {
	List useList(List lb) {
		lb.add(new Integer(17));
		return lb;
	}
}

JDK 1.5.0-beta-b32 reports a compile error "name clash: useList(java.util.List)
in p.B and useList(java.util.List<java.lang.String>) in p.A have the same
erasure, yet neither overrides the other", whereas the eclipse compiler
generates classfiles in which the methods do override. Running ...
public class User {
	public static void main(String[] args) {
		A a= new B();
		List list= new ArrayList();
		List list2= a.useList(list);
		System.out.println(list2.get(0));
	}
}
... with JDK 1.5.0-beta-b32 then prints 17.
Comment 1 Kent Johnson CLA 2004-08-03 14:10:58 EDT
Compiling & running this code with JDK 1.5.0-beta-b60 prints 17.

The compile error has been replaced with unchecked conversion warnings.
Comment 2 Kent Johnson CLA 2004-08-06 13:15:12 EDT
Fixed in HEAD & added tests 274-278.