Fwd: Single Abstract Method for SAMs cannot be polymorphic (original) (raw)
Grégoire Neuville gregoire.neuville at gmail.com
Wed Apr 3 03:57:24 PDT 2013
- Previous message: The stream abstraction and substream()
- Next message: Fwd: Single Abstract Method for SAMs cannot be polymorphic
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 {} @FunctionalInterface interface CoArbitrary { abstract Gen coarbitrary(A a, Gen 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
- Previous message: The stream abstraction and substream()
- Next message: Fwd: Single Abstract Method for SAMs cannot be polymorphic
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]