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

inference: failure of 15.12.2.8 should trigger backtracking in overload resolution

    Details

    • Subcomponent:
    • CPU:
      unknown
    • OS:
      generic

      Description

      The following legal Java program doesn't compile:

      class Test {
      <Z extends Number> Z m(String o) { return null; }
      <Z extends String> Z m(Object o) { return null; }

      { String s = m(null); } //error in javac
      }

      Reading JLS 3rd, section 15.12.2.2, method m(String) is not applicable - (because there's no instance of the type-variable Z satisfying the constraints imposed by the expected return type, as described in JLS 15.12.2.8). Hence, the applicability check fails and, method resolution discovers another suitable candidate, namely m(Object). javac seems to never get there.

        Attachments

          Issue Links

            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:
                  Imported:
                  Indexed: