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

Report unchecked warnings for method references

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • None
    • tools
    • None

      See spec bug JDK-8029640. An unchecked warning should occur if it is necessary to demonstrate the compatibility of the arguments or return type of a method reference.

      Example:

      import java.util.function.Function;

      public class UncheckedInvoke {

        Iterable<String> m1(Iterable<String> arg) { return arg; }
        Iterable m2(Iterable arg) { return arg; }
        
        void test(Iterable i) {
          Iterable i1 = m1(i); // expected: warning; actual: 2 warnings
          Iterable<String> i2 = m2(i); // expected: warning; actual: warning
        
          Function<Iterable, Iterable> f1 = this::m1; // expected: warning; actual: warning
          Function<Iterable, Iterable<String>> f2 = this::m2; // expected: warning; actual: warning
        }

      }

      I'm not entirely certain why there are two warnings for the invocation of m1 (perhaps to account for the special case in which, per 5.1.9, no unchecked warning occurs, but the signature is still erased?), but the behavior should probably be the same for the reference to m1.

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

              Created:
              Updated: