| Summary: | [1.7][compiler] Compiler should issue better diagnostics for use of <> with anonymous classes | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Srikanth Sankaran <srikanth_sankaran> | ||||
| Component: | Core | Assignee: | Srikanth Sankaran <srikanth_sankaran> | ||||
| Status: | VERIFIED FIXED | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | amj87.iitr, deepakazad, Olivier_Thomann | ||||
| Version: | 3.7 | ||||||
| Target Milestone: | 3.7.1 | ||||||
| Hardware: | PC | ||||||
| OS: | Windows XP | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
This was already part of the initial implementation for the diamond construct in bug 339478 comment 2. "2. ERROR in X.java (at line 3)\n" + " X Test = new X<>(){\n" + " ^\n" + "Empty type argument list cannot be used in anonymous class declaration\n" + "----------\n" Created attachment 195296 [details]
Proposed patch + tests
Patch under test. Note that prior to this patch, we were rejecting
the illegal programs correctly. Now the message makes it explicit to
the user that diamond cannot be used with anonymous classes.
Released in BETA_JAVA7 branch. Verified with v20110714-1300. |
BETA_JAVA7 head of branch. public class X<T> { X<String> x = new X<>() { }; } The program above elicits the error message: "Incorrect number of arguments for type X<T>; it cannot be parameterized with arguments <>" We could issue a better message that informs the user that his/her attempt to use <> with anonymous classes is disallowed.