Community
Participate
Working Groups
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) { } }
Please blame the Java language spec ! <g> Upper bounds can only be associated with wildcards, not type parameters.
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.
I am not sure this is worth the change, given this is the first time ever we get some user confusion here... low prio.
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.
Created attachment 94354 [details] New modified grammar for reference
I'm sorry for my premature post. I should have checked the language specification first. Generics are confusing enough as it is.
Was verified for 3.4M7 by reporter (comment 6).