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

jshell: Method cannot use its overloaded version

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b14
    • CPU:
      generic
    • OS:
      generic

      Description

      A DESCRIPTION OF THE PROBLEM :
      Definition of overloaded methods is possible until the method call its overloaded version.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      jshell> void pr(int i, String s) {
         ...> System.out.println(s + i);
         ...> }
      | created method pr(int,String)

      jshell> void pr(String s, int i) {
         ...> System.out.println(s + i);
         ...> }
      | created method pr(String,int)

      jshell> void pr(String s, int i) {
         ...> pr(i, s);
         ...> }
      | Error:
      | incompatible types: int cannot be converted to java.lang.String
      | pr(i, s);
      | ^
      | update overwrote method pr(String,int)

      jshell>


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Interpret discovers that I call the yet defined version.
      ACTUAL -
      Interpret is not able to call the existing version.

      ---------- BEGIN SOURCE ----------
      jshell> void pr(int i, String s) {
         ...> System.out.println(s + i);
         ...> }
      | created method pr(int,String)

      jshell> void pr(String s, int i) {
         ...> System.out.println(s + i);
         ...> }
      | created method pr(String,int)

      jshell> void pr(String s, int i) {
         ...> pr(i, s);
         ...> }
      | Error:
      | incompatible types: int cannot be converted to java.lang.String
      | pr(i, s);
      | ^
      | update overwrote method pr(String,int)

      jshell>

      ---------- END SOURCE ----------

      FREQUENCY : always


        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jlahoda Jan Lahoda
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: