Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8244559

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • repo-valhalla
    • repo-valhalla
    • tools
    • generic
    • generic

    Description

      Reported by Remi in amber-dev:

      The following program does not compile on Valhalla lworld head:

      // ---
      import java.util.List;

      public class X {
        @__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));
        }
      }

      // --
      error: cannot select a static class from a parameterized type
      X.java:18: error: method forEach in interface Stream<T> cannot be applied to given types;
          list.stream().forEach(e -> m(e));
                               ^
        required: Consumer<? super Foo$ref<Integer>>
        found: (e)->m(e)
        reason: argument mismatch; incompatible parameter types in lambda expression
        where T is a type-variable:
          T extends Object declared in interface Stream
      2 errors

      Attachments

        Issue Links

          Activity

            People

              sadayapalam Srikanth Adayapalam (Inactive)
              sadayapalam Srikanth Adayapalam (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: