Bug 225010 - [1.5][compiler] Unable to use "super" in generic methods
Summary: [1.5][compiler] Unable to use "super" in generic methods
Status: VERIFIED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.3   Edit
Hardware: PC Linux
: P3 normal with 1 vote (vote)
Target Milestone: 3.4 M7   Edit
Assignee: Philipe Mulet CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-03-31 18:28 EDT by Adam Crume CLA
Modified: 2008-04-28 11:15 EDT (History)
3 users (show)

See Also:


Attachments
New modified grammar for reference (85.11 KB, patch)
2008-04-01 09:21 EDT, Olivier Thomann CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adam Crume CLA 2008-03-31 18:28:57 EDT
The following code won't compile:
class Test<T> {
	<X super T> void test(X x) {
	}
}

The errors I get are "Syntax error on token "super", , expected" and "X cannot be resolved to a type".

However, this does compile:
class Test<T> {
	<X extends T> void test(X x) {
	}
}
Comment 1 Philipe Mulet CLA 2008-04-01 05:08:02 EDT
Please blame the Java language spec ! <g>

Upper bounds can only be associated with wildcards, not type parameters.
Comment 2 Olivier Thomann CLA 2008-04-01 08:40:42 EDT
We might however try to see if we can get rid of the syntax error to report a better error message. Maybe we can extend the grammar to accept an invalid construct and report the error later.
I'll see what I can do.
Comment 3 Philipe Mulet CLA 2008-04-01 09:08:35 EDT
I am not sure this is worth the change, given this is the first time ever we get some user confusion here... low prio.
Comment 4 Olivier Thomann CLA 2008-04-01 09:20:48 EDT
In fact even if the grammar can be modified to accept this case and fail with a better error message, since we need to add a new constant in IProblem it has to be done post 3.4.
M6 was API freeze.
Comment 5 Olivier Thomann CLA 2008-04-01 09:21:27 EDT
Created attachment 94354 [details]
New modified grammar for reference
Comment 6 Adam Crume CLA 2008-04-01 12:52:30 EDT
I'm sorry for my premature post.  I should have checked the language specification first.  Generics are confusing enough as it is.
Comment 7 Jerome Lanneluc CLA 2008-04-28 11:15:13 EDT
Was verified for 3.4M7 by reporter (comment 6).