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

Bug 350611

Summary: [1.7] Inconsistent error msg and error location for illegal diamond
Product: [Eclipse Project] JDT Reporter: Deepak Azad <deepakazad>
Component: CoreAssignee: Srikanth Sankaran <srikanth_sankaran>
Status: VERIFIED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: markus.kell.r, srikanth_sankaran
Version: 3.7   
Target Milestone: 3.7.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed patch none

Description Deepak Azad CLA 2011-06-28 13:11:42 EDT
With the following snippet I get this error - '<>' cannot be used in an allocation expression with explicit type arguments. 

It looks a bit odd that the error says "<> cannot be used" and then highlights "<String>"

---------------------------------------------------------------
class E {
	void foo1() {
		new <String> D<>();  // error on this line
	}
}

class D<T> {
	D(){}
	D(T i) {}	
}

---------------------------------------------------------------
Comment 1 Srikanth Sankaran CLA 2011-06-28 13:43:49 EDT
(In reply to comment #0)
> With the following snippet I get this error - '<>' cannot be used in an
> allocation expression with explicit type arguments. 
> 
> It looks a bit odd that the error says "<> cannot be used" and then highlights
> "<String>"

Would it be better if we flip the message and say "Explicit type arguments cannot be used with <> in an allocation expression" ? (and continue to highlight the explicit type arguments ?) As things stand we don't have the positions for the
<> very readily available.
Comment 2 Markus Keller CLA 2011-06-28 13:59:37 EDT
(In reply to comment #1)
Sounds good to me.
Comment 3 Srikanth Sankaran CLA 2011-06-28 14:04:13 EDT
Ayush, please follow up. TIA.
Comment 4 Deepak Azad CLA 2011-06-28 14:06:37 EDT
(In reply to comment #1)
> Would it be better if we flip the message and say "Explicit type arguments
> cannot be used with <> in an allocation expression" ? (and continue to
> highlight the explicit type arguments ?) As things stand we don't have the
> positions for the
> <> very readily available.

Yeah, this is better.
Comment 5 Srikanth Sankaran CLA 2011-07-05 05:14:02 EDT
As Ayush is busy with other issues, I'll take this one.
Comment 6 Srikanth Sankaran CLA 2011-07-05 05:26:56 EDT
Created attachment 199102 [details]
Proposed patch

This patch changes the message to the agreed upon one.
Comment 7 Srikanth Sankaran CLA 2011-07-05 07:05:24 EDT
Released in BETA_JAVA7 branch.
Comment 8 Deepak Azad CLA 2011-07-19 07:56:55 EDT
Verified with v20110714-1300.