Details

    • Type: Sub-task
    • Status: Closed
    • Priority: P4
    • Resolution: Delivered
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: tools
    • Subcomponent:
    • Verification:
      Verified

      Description

      `javac` does not generate unchecked warnings when checking method reference return types.

      ```
      import java.util.function.*;
      import java.util.*;
       
      class Test {
         void m() {
            IntFunction<List<String>[]> sls = List[]::new; //warning
            Supplier<List<String>> sls = this::l; //warning
         }
       
         List l() { return null; }
      }
      ```
       
      Starting from <version>, `javac` will emit a warning when unchecked conversion is required for a method reference to be compatible with a functional interface target.

      This change brings the compiler in sync with JLS section 15.13.2:

      > A compile-time unchecked warning occurs if unchecked conversion was necessary for the compile-time declaration to be applicable, and this conversion would cause an unchecked warning in an invocation context.
       
      and,

      > A compile-time unchecked warning occurs if unchecked conversion was necessary for the return type R', described above, to be compatible with the function type's return type, R, and this conversion would cause an unchecked warning in an assignment context.

        Attachments

          Activity

            People

            • Assignee:
              mcimadamore Maurizio Cimadamore
              Reporter:
              mcimadamore Maurizio Cimadamore
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: