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
I can reproduce this minimally as follows:
This seems to be either a bug or a limitation in Java, and it makes
NilToObjEmuch less useful than it should be.I'm planning to bump to 2.0 with a version that doesn't extend
Callable.