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

Need to perform capture on unbound method reference type

    Details

    • Type: Bug
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 8
    • Fix Version/s: tbd_minor
    • Component/s: tools
    • Labels:

      Description

      javac should be updated to conform to Lambda Spec bug fix JDK-8029306.

      The spec failed to account for the possibility that the qualifying type of an unbound method reference might be a wildcard-parameterized type.

      The fix is to perform capture conversion on this type (as well as the type that is inferred to fill in type arguments for a raw type).

      The following should compile without error:
        Function<Optional<?>, Object> f1 = Optional<?>::get;
        Function<Optional<Integer>, Number> f2 = Optional<? extends Number>::get;
        Function<LinkedList<? extends Integer>, Integer> f3 = Queue::peek;

      Current errors (tested b115):

      error: incompatible types: invalid method reference
        Function<Optional<?>, Object> f1 = Optional<?>::get;
                                           ^
          method get in class Optional<T> cannot be applied to given types
            required: no arguments
            found: Optional<?>
            reason: actual and formal argument lists differ in length
        where T is a type-variable:
          T extends Object declared in class Optional

      error: incompatible types: invalid method reference
        Function<Optional<Integer>, Number> f2 = Optional<? extends Number>::get;
                                                 ^
          method get in class Optional<T> cannot be applied to given types
            required: no arguments
            found: Optional<Integer>
            reason: actual and formal argument lists differ in length
        where T is a type-variable:
          T extends Object declared in class Optional

      AbstractCRef.java:7: error: incompatible types: bad return type in method reference
        Function<LinkedList<? extends Integer>, Integer> f3 = Queue::peek;
                                                              ^
          ? extends Integer cannot be converted to Integer

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vromero Vicente Arturo Romero Zaldivar
                Reporter:
                dlsmith Dan Smith
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: