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

18.5.2: Need broader definition of "dependency" between input/output variables

XMLWordPrintable

      The order in which implicitly-typed lambdas are checked in 18.5.2 depends on the relationship between the "input variables" of one constraint and the "output variables" of another. Currently, a constraint can be resolved if:

      "no input variable depends on an output variable of another constraint in C (input variable and output variable are defined below; dependencies between inference variable are defined in 18.4)"

      The dependencies between inference variables, defined in 18.4, are inadequate to express all cases in which information might flow from one variable to another. This was recognized when implementing javac, leading to two concepts of dependency: "strong" dependencies for resolution, and "weak" dependencies for ordering constraints. The javac behavior needs to be reflected in JLS.

      In particular, a bound of the form 'a <: Foo<b>' generally implies a one-way dependency of 'a' on 'b'. But, for constraint sequencing, it would also be valuable to get more information about 'a' before resolving 'b'.

      Example:

      <A extends List<B>, B> m(Consumer<B> arg1, Supplier<A> arg2);
      m(b -> System.out.println(b.length()), () -> new ArrayList<String>())

            abuckley Alex Buckley
            dlsmith Dan Smith
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: