static/instance overload leads to 'unexpected static method found in unbound lookup' when resolving method reference

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 16
    • Affects Version/s: 11, 14
    • Component/s: tools
    • b33

      Minimized test case:

      import java.util.function.*;
       
      public class Test {
          public String foo(Object o) { return "foo"; }
          public static String foo(String o) { return "bar"; }

          public void test() {
              Function<String, String> f = Test::foo;
          }
      }

      $ javac -version
      javac 1.8.0_212
      $ javac Test.java
      <OK>

      $ ~/trunks/jdk-jdk/build/linux-x86_64-server-release/images/jdk/bin/javac -version
      javac 14-internal
      $ ~/trunks/jdk-jdk/build/linux-x86_64-server-release/images/jdk/bin/javac Test.java
      Test.java:8: error: incompatible types: invalid method reference
           Function<String, String> f = Test::foo;
           ^
          unexpected static method foo(String) found in unbound lookup
      1 error

      So it works on 8, and fails on 11, 14.

        1. 8231461.patch
          1 kB
          Maurizio Cimadamore

            Assignee:
            Vicente Arturo Romero Zaldivar
            Reporter:
            Aleksey Shipilev
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: