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

Bug 353452

Summary: [1.7][quick fix] Quick fix for explicit type arguments with diamond operator
Product: [Eclipse Project] JDT Reporter: Ayushman Jain <amj87.iitr>
Component: UIAssignee: JDT-UI-Inbox <jdt-ui-inbox>
Status: ASSIGNED --- QA Contact:
Severity: enhancement    
Priority: P5 CC: daniel_megert, markus.kell.r
Version: 3.7   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:

Description Ayushman Jain CLA 2011-07-30 02:56:21 EDT
BETA_JAVA7

public class DiamondTest<T> {
	
	public <U> DiamondTest(T t) {
		
	}

	public static void main ( String[] args ) {
		DiamondTest<String> d = new <Integer> DiamondTest<>();

	}

}

On the error at <Integer> above, there can be a quick fix which inserts <String> in place of <>.

(Sorry if i'm filing a dup.)
Comment 1 Markus Keller CLA 2011-08-02 16:01:40 EDT
The RHS also needs an actual method argument (e.g. ""). Then the best fix would be to turn it into
    new DiamondTest<>("");
not
    new <Integer>DiamondTest<String>("");

I don't think we should spend time on this, since explicit constructor type arguments are rare in practice. In the given example, the compiler would first have to be fixed to compute the right type binding for the ClassInstanceCreation.