FULL PRODUCT VERSION :
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
6.1.7601
A DESCRIPTION OF THE PROBLEM :
The example code doesn't compile and fails with a type inference error. It does, however, compile just fine in Eclipse Mars.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
method c in enum Q cannot be applied to given types;
return c(f::e);
^
required: Consumer<S<? super T#1>>
found: f::e
reason: cannot infer type-variable(s) T#1
(argument mismatch; invalid method reference
incompatible types: S<CAP#1> cannot be converted to S<? super CAP#2>)
where T#1,T#2 are type-variables:
T#1 extends Object declared in method <T#1>c(Consumer<S<? super T#1>>)
T#2 extends Object declared in method <T#2>f(P<? extends T#2>)
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends Object super: T#1 from capture of ? super T#1
CAP#2 extends T#2 from capture of ? extends T#2
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public enum Q {
;
interface S<T> {
}
interface P<T> {
void e(S<? super T> s);
}
static <T> P<T> c(Consumer<S<? super T>> c) {
return null;
}
static <T> P<T> f(P<? extends T> f) {
return c(f::e);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Instead of method reference, use a full lambda:
return c(a -> f.e(a));
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27)
Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
6.1.7601
A DESCRIPTION OF THE PROBLEM :
The example code doesn't compile and fails with a type inference error. It does, however, compile just fine in Eclipse Mars.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
method c in enum Q cannot be applied to given types;
return c(f::e);
^
required: Consumer<S<? super T#1>>
found: f::e
reason: cannot infer type-variable(s) T#1
(argument mismatch; invalid method reference
incompatible types: S<CAP#1> cannot be converted to S<? super CAP#2>)
where T#1,T#2 are type-variables:
T#1 extends Object declared in method <T#1>c(Consumer<S<? super T#1>>)
T#2 extends Object declared in method <T#2>f(P<? extends T#2>)
where CAP#1,CAP#2 are fresh type-variables:
CAP#1 extends Object super: T#1 from capture of ? super T#1
CAP#2 extends T#2 from capture of ? extends T#2
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public enum Q {
;
interface S<T> {
}
interface P<T> {
void e(S<? super T> s);
}
static <T> P<T> c(Consumer<S<? super T>> c) {
return null;
}
static <T> P<T> f(P<? extends T> f) {
return c(f::e);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Instead of method reference, use a full lambda:
return c(a -> f.e(a));