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

type inference regression after JDK-8046685

    Details

    • Subcomponent:
    • Introduced In Build:
      b93
    • Resolved In Build:
      b03

      Backports

        Description

        The following program is rejected by javac after the fix for JDK-8046685.

        Adding explicit lambda parameter types works around the problem:

        - a(r, c(o(new P<>(s -> s.isEmpty()))));
        + a(r, c(o(new P<>((String s) -> s.isEmpty()))));

        ===
        import java.util.List;
        import java.util.function.Predicate;

        abstract class T {

          void f(List<String> r) {
            a(r, c(o(new P<>(s -> s.isEmpty()))));
          }

          abstract <U> List<U> o(U e);
          abstract <E> Predicate<List<? extends E>> c(List<Predicate<? super E>> xs);
          abstract <T> void a(T a, Predicate<? super T> m);

          static class P<V> implements Predicate<V> {
            public P(Predicate<V> p) {}
            public boolean test(V t) { return false; }
          }
        }
        ===

        T.java:7: error: cannot find symbol
            a(r, c(o(new P<>(s -> s.isEmpty()))));
                                   ^
          symbol: method isEmpty()
          location: variable s of type V
          where V is a type-variable:
            V extends Object declared in class P
        T.java:7: error: incompatible types: inference variable V has incompatible bounds
            a(r, c(o(new P<>(s -> s.isEmpty()))));
             ^
            equality constraints: V
            lower bounds: String,E
          where V,E are type-variables:
            V extends Object declared in class P
            E extends Object declared in method <E>c(List<Predicate<? super E>>)
        2 errors

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  vromero Vicente Arturo Romero Zaldivar
                  Reporter:
                  cushon Liam Miller-Cushon
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: