Fwd: Single Abstract Method for SAMs cannot be polymorphic
Grégoire Neuville
gregoire.neuville at gmail.com
Wed Apr 3 03:57:24 PDT 2013
Thanks for the clarification. Is it a temporary or permanent limitation ?
On 2 April 2013 22:23, Brian Goetz <brian.goetz at oracle.com> wrote:
> Not actually true. SAM methods can be generic. However, the only way to
> assign to such a SAM is with a method reference to a generic method.
> There's no syntax for *lambdas* that allows you to specify the type params.
>
> You should be able to use Gen::new in your example (though not sure if the
> wildcards are going to mess it up.)
>
>
>
> On 4/2/2013 4:04 PM, Grégoire Neuville wrote:
>
>> Hi all,
>>
>> The below code :
>>
>> public class TestGenericSAM {
>>
>> class Gen<B> {}
>>
>> @FunctionalInterface
>> interface CoArbitrary<A> {
>> abstract <B> Gen<B> coarbitrary(A a, Gen<B> g);
>> }
>>
>> void test() {
>> CoArbitrary<?> coArb = (a, g) -> new Gen<>();
>> }
>> }
>>
>> doesn't compile. I guess this is by design (the annotation alone is marked
>> as erroneous by IntelliJ), but I'm just wondering why.
>>
>> Thanks a lot for any explanation !
>>
>>
--
Grégoire Neuville
--
Grégoire Neuville
More information about the lambda-dev
mailing list