Friday, 9 August 2013

"Unexpected token" using lower-bounded wildcard (Java)

"Unexpected token" using lower-bounded wildcard (Java)

I have something along the lines of:
interface Foo<T> {
//... lines [0,45]...
/*line 46*/ <R, X super T&R> List<X> weave(R value);
//...
}
But IntelliJ is reporting:
Error:(46, 18) java: > expected
Error:(46, 19) java: illegal start of type
Error:(46, 26) java: '(' expected
Error:(46, 28) java: < identifier > expected
Error:(46, 29) java: 'l' expected
Error:(46, 43) java: < identifier > expected
What's the problem? Am I not allowed to bind a name to a lower bound? Or
am I only allowed to use a R&X expression in an upper bound?
Changing it to
interface Foo<T> {
//... lines [0,45]...
/*line 46*/ <R> List<? super T&R> weave(R value);
//...
}
yields
Error(46, 31) java: > expected
Error(46, 32) java: '(' expected
Error(46, 33) java: illegal start of type

No comments:

Post a Comment