Bug 77142 - [1.5] calling generic static method in generic class causes erroneous type mismatch error
Summary: [1.5] calling generic static method in generic class causes erroneous type mi...
Status: RESOLVED DUPLICATE of bug 76313
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M3   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-10-27 14:01 EDT by Dave Latham CLA
Modified: 2004-10-27 18:52 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Latham CLA 2004-10-27 14:01:11 EDT
3.1M2, java 1.5.0rc

The following code compiles fine on the command line, but Eclipse doesn't like it:

class MyClass<T> {
	
	private T thing;
	
	public
	MyClass(T thing) {
		this.thing = thing;
	}
	
	public static <U> MyClass<U>
	factoryMakeMyClass(U thing)	{
		return new MyClass<U>(thing);
	}
}

class External {

	public static <U> MyClass<U>
	factoryMakeMyClass(U thing)	{
		return new MyClass<U>(thing);
	}
}

class Test {
	public static void
	test()
	{
		// No problem with this line:
		MyClass<String> foo = External.factoryMakeMyClass("hi");
		
		// This line gives me an error:
		// Type mismatch: cannot convert from MyClass<Object> to MyClass<String>
		MyClass<String> bar = MyClass.factoryMakeMyClass("hi");
	}
}
Comment 1 Philipe Mulet CLA 2004-10-27 18:51:55 EDT

*** This bug has been marked as a duplicate of 76313 ***