-
Bug
-
Resolution: Fixed
-
P4
-
None
-
b93
-
b03
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8176443 | 9 | Vicente Arturo Romero Zaldivar | P4 | Closed | Fixed | b161 |
The following program is rejected by javac after the fix for JDK-8046685.
Adding explicit lambda parameter types works around the problem:
- a(r, c(o(new P<>(s -> s.isEmpty()))));
+ a(r, c(o(new P<>((String s) -> s.isEmpty()))));
===
import java.util.List;
import java.util.function.Predicate;
abstract class T {
void f(List<String> r) {
a(r, c(o(new P<>(s -> s.isEmpty()))));
}
abstract <U> List<U> o(U e);
abstract <E> Predicate<List<? extends E>> c(List<Predicate<? super E>> xs);
abstract <T> void a(T a, Predicate<? super T> m);
static class P<V> implements Predicate<V> {
public P(Predicate<V> p) {}
public boolean test(V t) { return false; }
}
}
===
T.java:7: error: cannot find symbol
a(r, c(o(new P<>(s -> s.isEmpty()))));
^
symbol: method isEmpty()
location: variable s of type V
where V is a type-variable:
V extends Object declared in class P
T.java:7: error: incompatible types: inference variable V has incompatible bounds
a(r, c(o(new P<>(s -> s.isEmpty()))));
^
equality constraints: V
lower bounds: String,E
where V,E are type-variables:
V extends Object declared in class P
E extends Object declared in method <E>c(List<Predicate<? super E>>)
2 errors
Adding explicit lambda parameter types works around the problem:
- a(r, c(o(new P<>(s -> s.isEmpty()))));
+ a(r, c(o(new P<>((String s) -> s.isEmpty()))));
===
import java.util.List;
import java.util.function.Predicate;
abstract class T {
void f(List<String> r) {
a(r, c(o(new P<>(s -> s.isEmpty()))));
}
abstract <U> List<U> o(U e);
abstract <E> Predicate<List<? extends E>> c(List<Predicate<? super E>> xs);
abstract <T> void a(T a, Predicate<? super T> m);
static class P<V> implements Predicate<V> {
public P(Predicate<V> p) {}
public boolean test(V t) { return false; }
}
}
===
T.java:7: error: cannot find symbol
a(r, c(o(new P<>(s -> s.isEmpty()))));
^
symbol: method isEmpty()
location: variable s of type V
where V is a type-variable:
V extends Object declared in class P
T.java:7: error: incompatible types: inference variable V has incompatible bounds
a(r, c(o(new P<>(s -> s.isEmpty()))));
^
equality constraints: V
lower bounds: String,E
where V,E are type-variables:
V extends Object declared in class P
E extends Object declared in method <E>c(List<Predicate<? super E>>)
2 errors
- backported by
-
JDK-8176443 type inference regression after JDK-8046685
- Closed
- relates to
-
JDK-8185655 type inference regression after JDK-8175235
- Open
-
JDK-8046685 Uncompilable large expressions involving generics.
- Closed