2015-09-07 11:44:36 -06:00
|
|
|
|
// generics/SelfBoundingAndCovariantArguments.java
|
2015-06-15 17:47:35 -07:00
|
|
|
|
// <20>2015 MindView LLC: see Copyright.txt
|
|
|
|
|
|
|
|
|
|
interface SelfBoundSetter<T extends SelfBoundSetter<T>> {
|
|
|
|
|
void set(T arg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Setter extends SelfBoundSetter<Setter> {}
|
|
|
|
|
|
|
|
|
|
public class SelfBoundingAndCovariantArguments {
|
|
|
|
|
void testA(Setter s1, Setter s2, SelfBoundSetter sbs) {
|
|
|
|
|
s1.set(s2);
|
|
|
|
|
// s1.set(sbs); // Error:
|
|
|
|
|
// set(Setter) in SelfBoundSetter<Setter>
|
|
|
|
|
// cannot be applied to (SelfBoundSetter)
|
|
|
|
|
}
|
2015-09-07 11:44:36 -06:00
|
|
|
|
}
|