inference of throws type parameters in SAMs
Maurizio Cimadamore
maurizio.cimadamore at oracle.com
Tue Oct 30 09:30:03 PDT 2012
On 30/10/12 16:18, Peter Levart wrote:
> Which indicates that the inference algorithm does it's job correctly.
> But the following program:
>
> public static void main(String... args)
> {
> MyStream<String> stream = null;
>
> String first = stream.findFirstOrElse(() -> "NO VALUE");
> }
>
>
> Triggers the compilation failure:
>
> error: unreported exception Throwable; must be caught or declared to be
> thrown
> String first = stream.findFirstOrElse(() -> "NO VALUE");
There are no constraints on the inference variable E - so, the language
infers E to be the declared bound, namely Throwable. What type do you
suggest the language/compiler infer in such situation?
Maurizio
More information about the lambda-dev
mailing list