-
Bug
-
Resolution: Duplicate
-
P4
-
8
-
unknown
-
generic
This program doesn't compile:
class Foo<X> {
<Z> Foo test() { return null; }
Foo<?> foo = test();
}
The compiler reports the following message:
Test.java:3: error: incompatible types; no instance(s) of type variable(s) Z exist so that Foo conforms to Foo<?>
Foo<?> foo = test();
^
required: Foo<?>
found: <Z>Foo
where Z is a type-variable:
Z extends Object declared in method <Z>test()
1 error
class Foo<X> {
<Z> Foo test() { return null; }
Foo<?> foo = test();
}
The compiler reports the following message:
Test.java:3: error: incompatible types; no instance(s) of type variable(s) Z exist so that Foo conforms to Foo<?>
Foo<?> foo = test();
^
required: Foo<?>
found: <Z>Foo
where Z is a type-variable:
Z extends Object declared in method <Z>test()
1 error
- duplicates
-
JDK-8015505 Spurious inference error when return type of generic method requires unchecked conversion to target
- Closed