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

Bug 346026

Summary: [1.7][compiler] Eclipse fails to compile diamond usage
Product: [Eclipse Project] JDT Reporter: Srikanth Sankaran <srikanth_sankaran>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: amj87.iitr, jarthana, Olivier_Thomann, satyam.kandula
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Srikanth Sankaran CLA 2011-05-16 23:46:53 EDT
Top of BETA_JAVA7 branch:

class C {}
interface I {}

public class X<T extends C & I> {
    X() {}
    X f = new X<>();
}

This code doesn't compile with eclipse, JDK7b138 compiles it OK.
Comment 1 Srikanth Sankaran CLA 2011-05-16 23:47:30 EDT
I'll follow up.
Comment 2 Srikanth Sankaran CLA 2011-05-17 00:08:37 EDT
Problem stems from eclipse's underlying failure
to compile this code:


class C {}
interface I {}

public class X<T extends C & I> {
	static <U extends C & I> X<U> getX() {
		return null;
	}
    X f2 = getX();
}


See that javac 5 & 6 reject this code as well with:

X.java:8: type parameters of <U>X<U> cannot be determined; no unique maximal ins
tance exists for type variable U with upper bounds C,I
    X f2 = getX();
               ^

7b138 compiles it alright. Under investigation.\
Comment 3 Srikanth Sankaran CLA 2011-05-17 01:14:49 EDT
Released disabled junit via org.eclipse.jdt.core.tests.compiler.regression.GenericsRegressionTest_1_7._test0030()
Comment 4 Srikanth Sankaran CLA 2011-05-17 05:21:26 EDT
See also that eclipse fails to compile the following:

class C {}
interface I {}

public class X<T extends C & I> {
    static <U extends C & I> X<U> getX() {
        return null;
    }
    X<?> f2 = getX();
}

while javac 5,6,7 all compile it alright.
Comment 5 Srikanth Sankaran CLA 2011-05-24 18:58:46 EDT
Same as bug 341795

*** This bug has been marked as a duplicate of bug 341795 ***
Comment 6 Satyam Kandula CLA 2011-06-29 03:17:14 EDT
Verified using Java 7 feature patch.