-
Enhancement
-
Resolution: Fixed
-
P4
-
5.0
-
b71
-
generic
-
generic, solaris_8
-
Verified
The error message uses 'incompatible types' with the notation '=?', which I"m nost sure is all that clear. Will users be familiar with '=' in generic notation enough to diagnose? I wish I had a better suggestion, maybe something about writing to a read only class.
class test
{
class A {}
class B extends A {}
class List<T> { List<T> next; T t; }
<A> List<? extends A> bad_reverse(List<? extends A> xs)
{
List<? extends A> tmp1 = xs, tmp2 = xs.next;
tmp2.next = tmp1; // <<fail>> attempt to write to readonly class
return tmp1;
}
}
----------error message-----------
test.java:21: incompatible types
found : test.List<? extends A>
required: test.List<=? extends A>
tmp2.next = tmp1; // <<fail>>
^
class test
{
class A {}
class B extends A {}
class List<T> { List<T> next; T t; }
<A> List<? extends A> bad_reverse(List<? extends A> xs)
{
List<? extends A> tmp1 = xs, tmp2 = xs.next;
tmp2.next = tmp1; // <<fail>> attempt to write to readonly class
return tmp1;
}
}
----------error message-----------
test.java:21: incompatible types
found : test.List<? extends A>
required: test.List<=? extends A>
tmp2.next = tmp1; // <<fail>>
^