-
Notifications
You must be signed in to change notification settings - Fork 3
NilToObjE type inference breaks with lambdas #2
Copy link
Copy link
Closed
Description
I can reproduce this minimally as follows:
import java.util.concurrent.Callable;
public class ExceptionInference {
public static void main(String[] args) {
String s = testInference(new NilToObjE<String, RuntimeException>() {
@Override
public String call() {
return "compiles";
}
});
s = testInference(new NilToObjE<String, RuntimeException>() {
@Override
public String call() {
throw new RuntimeException("compiles");
}
});
s = testInference(() -> "doesn't compile");
s = testInference(() -> {
throw new RuntimeException("doesn't compile");
});
}
static <R, E extends Exception> R testInference(NilToObjE<R, E> f) throws E {
return f.call();
}
@FunctionalInterface
interface NilToObjE<R, E extends Exception> extends Callable<R> {
@Override
R call() throws E;
}
}This seems to be either a bug or a limitation in Java, and it makes NilToObjE much less useful than it should be.
I'm planning to bump to 2.0 with a version that doesn't extend Callable.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels