Bug 186822 - [1.5][compiler] Add more resilience on annotation and enum type declaration with type parameters
Summary: [1.5][compiler] Add more resilience on annotation and enum type declaration w...
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-05-14 11:58 EDT by Olivier Thomann CLA
Modified: 2007-07-11 09:42 EDT (History)
2 users (show)

See Also:
david_audel: review+


Attachments
Proposed fix (23.77 KB, patch)
2007-05-14 11:59 EDT, Olivier Thomann CLA
no flags Details | Diff
Parser resources (27.60 KB, application/octet-stream)
2007-05-14 11:59 EDT, Olivier Thomann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2007-05-14 11:58:02 EDT
Right now the following test case fails with a syntax error:
public @interface X<T> {
	
	Zork foo();
}
----------
1. ERROR in X.java (at line 1)
        public @interface X<T> {
                          ^
Syntax error on token "X", { expected after this token
----------
2. ERROR in X.java (at line 1)
        public @interface X<T> {
                               ^
Syntax error, insert "}" to complete Block
----------
3. ERROR in X.java (at line 1)
        public @interface X<T> {

        Zork foo();
                               ^^^^^^
The interface X cannot define an initializer
----------
4. ERROR in X.java (at line 3)
        Zork foo();
        ^^^^
Zork cannot be resolved to a type
----------
4 problems (4 errors)

we could change it to also report the error on Zork.
----------
1. ERROR in D:\tests_sources\X.java (at line 1)
	public @interface X<T> {
	                    ^
Syntax error, annotation declaration cannot have type parameters
----------
2. ERROR in D:\tests_sources\X.java (at line 3)
	Zork foo();
	^^^^
Zork cannot be resolved to a type
----------
2 problems (2 errors)

This is much more understandable for the user.
Comment 1 Olivier Thomann CLA 2007-05-14 11:59:31 EDT
Created attachment 67090 [details]
Proposed fix
Comment 2 Olivier Thomann CLA 2007-05-14 11:59:59 EDT
Created attachment 67091 [details]
Parser resources

Unzip in the Parser folder.
Comment 3 David Audel CLA 2007-05-15 06:12:19 EDT
The patch looks good.
Comment 4 Olivier Thomann CLA 2007-05-15 10:23:01 EDT
Enum should also be improved.
Updating title accordingly.
Comment 5 Olivier Thomann CLA 2007-07-11 09:42:09 EDT
Released in HEAD.
Added regression tests in org.eclipse.jdt.core.tests.compiler.regression.AnnotationTest#test227 and
org.eclipse.jdt.core.tests.compiler.regression.EnumTest#test144.
I also updated existing diet recovery test for the annotations.

David, please review the changes.