Single Abstract Method for SAMs cannot be polymorphic (original) (raw)
Brian Goetz brian.goetz at oracle.com
Tue Apr 2 13:23:54 PDT 2013
- Previous message: Single Abstract Method for SAMs cannot be polymorphic
- Next message: hg: lambda/lambda/jdk: Rename methods in PipelineHelper to be more consistent
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 !
- Previous message: Single Abstract Method for SAMs cannot be polymorphic
- Next message: hg: lambda/lambda/jdk: Rename methods in PipelineHelper to be more consistent
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]