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

Most-specific should not have any special treatment for boxed vs. unboxed types

    XMLWordPrintable

Details

    • b14
    • Verified

    Backports

      Description

        The following compiles with javac 8 b121:

        static void m(Object dummy, int arg) { System.out.println("int"); }
        static void m(Object dummy, Integer arg) { System.out.println("Integer"); }

        public static void main(String... args) {
          m(0, 23);
          m(0, Integer.valueOf(23));
        }

        (The first invocation prints "int"; the second prints "Integer".)

        This was an experimental feature in Lambda that we ultimately agreed to undo for 8. The return expressions of _lambdas_ should continue to get special treatment, but a top-level argument should not. The only mechanism for treating one parameter type as better than another in this case should be subtyping.

        Attachments

          Issue Links

            Activity

              People

                dlsmith Dan Smith
                dlsmith Dan Smith
                Votes:
                0 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: