Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 231094

Summary: [1.5][compiler] Compiler warns on method call with partial raw types where Sun errors
Product: [Eclipse Project] JDT Reporter: William Whittle <william.whittle>
Component: CoreAssignee: Philipe Mulet <philippe_mulet>
Status: VERIFIED DUPLICATE QA Contact:
Severity: major    
Priority: P3 CC: philippe_mulet
Version: 3.3.2   
Target Milestone: 3.5 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description William Whittle CLA 2008-05-08 06:29:46 EDT
Build ID: M20080221-1800

Steps To Reproduce:
Please see the code snippet below that exhibits this problem. No combination of compiler settings available on the Eclipse compiler dialogue bring Eclipse's behaviour in line with Sun's.

1. Declare a method that defines a parameterised type as extending some type, and uses this parameterised type more than once in its arguments.
2. Call that method specifying one parameter correctly and one raw.
3. Compile with both Eclipse and Sun Java 5 SDK.


More information:
public class Test
{
	public static void main(String[] args)
	{
		Test test = new Test();
		
		/* OK: Bob.class is correct. No idea about the Thingy */
		test.doStuff(Bob.class, new Thingy());
		
		/*
		 * This line will fail when compiled with the Java 5 SDK:
		 * 
		 * Test.java:25: <T>doStuff(java.lang.Class<T>,Thingy<T>) in Test cannot be applied to (java.lang.Class<Bill>,Thingy)
         *      test.doStuff(Bill.class, new Thingy());
         *          ^
		 * Note: Test.java uses unchecked or unsafe operations.
		 * Note: Recompile with -Xlint:unchecked for details.
		 * 1 error
		 */
		test.doStuff(Jim.class, new Thingy());
	}
	
	<T extends Bob> void doStuff(Class<T> klass, Thingy<T> thingy)
	{
	}
}

class Jim
{
}

class Bob
{
}

class Bob2 extends Bob
{
}

class Thingy<T extends Bob>
{
}
Comment 1 Philipe Mulet CLA 2008-05-09 06:49:22 EDT
I believe the inference is detecting presence of raw type Thingy, and thus elects a raw form of the method to be invoked. Hence a warning, and no error.
Comment 2 Philipe Mulet CLA 2008-05-16 05:11:54 EDT
Added GenericTypeTest#test1322-1328 (some disabled until resolution)
Comment 3 Philipe Mulet CLA 2008-12-18 06:26:21 EST
ECJ shouldn't be erasing entire method signature in presence of unchecked conversion during type inference.
It should strictly apply JLS15.12.2.6 instead (erase return type & thrown exceptions).

Comment 4 Philipe Mulet CLA 2008-12-18 06:33:10 EST
also see bug 258798
Comment 5 Philipe Mulet CLA 2009-01-08 11:33:59 EST
Closing as dup of 258798. Strict application of 15.12.2.6 is addressing the problem.

*** This bug has been marked as a duplicate of bug 258798 ***
Comment 6 Frederic Fusier CLA 2009-01-27 07:08:36 EST
Verified for 3.5M5 using build I20090127-0100.