Single Abstract Method for SAMs cannot be polymorphic

Grégoire Neuville gregoire.neuville at
Tue Apr 2 13:04:32 PDT 2013

Hi all,

The below code :

public class TestGenericSAM {

  class Gen<B> {}

  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

More information about the lambda-dev mailing list