Lambda and parameterized ref of an inline type doesn't work well

Remi Forax forax at univ-mlv.fr
Wed May 6 22:37:14 UTC 2020


  @__inline__ static class Foo<V> {
    int x;
    Foo(int x) { this.x = x; }
  }

  static void m(Foo foo) {
    System.out.println("inline");
  }
  static void m(Foo.ref foo) {
    System.out.println("ref");
  }

  public static void main(String[] args) {
    List<Foo.ref<Integer>> list = List.of(new Foo<Integer>(3)); 
    list.stream().forEach(e -> m(e));
  }

I don't even understand the error message when playing with parameterized ref of an inline type.

error: cannot select a static class from a parameterized type
Hello.java:19: error: incompatible types: incompatible parameter types in lambda expression
    list.stream().forEach(e -> m(e));
                          ^

regards,
Rémi


More information about the amber-dev mailing list