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

Lambda Spec: Take multiple upper bounds into account in incorporation

    Details

    • Subcomponent:
    • Verification:
      Verified

      Description

      Consider two upper bounds, at least one of which mentions an inference variable:
      a <: Foo<b>
      a <: Bar<String>

      If these upper bounds share a parameterized type, we can infer additional constraints from the type arguments (e.g., maybe b = String).

      Here's an example (notably, this compiles in 7, due to a quirk in javac's implementation):

      interface Task<E extends Exception> {}
      class Comparator<T> {}
      class CustomException extends Exception {}

      class TaskQueue<E extends Exception, T extends Task<E>> {}

      abstract class Test {
       abstract <E extends Exception, T extends Task<E>>
           TaskQueue<E, T> create(Comparator<? super T> comparator);

       void f(Comparator<Task<CustomException>> comp) {
         TaskQueue<CustomException, Task<CustomException>> queue = create(comp);
       }
      }

      Reported on lambda-dev: http://mail.openjdk.java.net/pipermail/lambda-dev/2013-November/011442.html

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                dlsmith Dan Smith
                Reporter:
                dlsmith Dan Smith
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: