^V/*
* @test @(#)InstanceOf.java
* @summary type comparison and type cast with instanceof
* @compile InstanceOf.java
*/
class InstanceOf<T>
{
static interface I1<T>
{
public T[] toArray();
}
static interface I2<T> extends I1<T>
{
public T[] toArray();
}
static interface I3<T> extends I2<T> { }
InstanceOf()
{
I1<T> inv = null;
I1<? extends T> cov = null;
I1<? super T> con = null;
boolean b;
b = inv instanceof I3; // <<pass>>
b = cov instanceof I3; // <<pass>> THIS FAILS
b con instanceof I3; // <<pass>>
}
}
//InstanceOf.java:25: types InstanceOf.I1<? extends T> and InstanceOf.I3 are
//incompatible; both define toArray(), but with different return type
// b = cov instanceof I3; // <<pass>> <<todo: casts>>
^
* @test @(#)InstanceOf.java
* @summary type comparison and type cast with instanceof
* @compile InstanceOf.java
*/
class InstanceOf<T>
{
static interface I1<T>
{
public T[] toArray();
}
static interface I2<T> extends I1<T>
{
public T[] toArray();
}
static interface I3<T> extends I2<T> { }
InstanceOf()
{
I1<T> inv = null;
I1<? extends T> cov = null;
I1<? super T> con = null;
boolean b;
b = inv instanceof I3; // <<pass>>
b = cov instanceof I3; // <<pass>> THIS FAILS
b con instanceof I3; // <<pass>>
}
}
//InstanceOf.java:25: types InstanceOf.I1<? extends T> and InstanceOf.I3 are
//incompatible; both define toArray(), but with different return type
// b = cov instanceof I3; // <<pass>> <<todo: casts>>
^