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

Inference failure with nested invocation

    Details

    • Subcomponent:
    • Resolved In Build:
      b32
    • Verification:
      Verified

      Backports

        Description

        The following fails to compile:

        ---

        public class FirstNonNull {

        public static class C<T> {}

        public static <T> T firstNonNull(T first, T second) {
            return first != null ? first : second;
        }

        public static C<String> doesNotCompile = firstNonNull(new C<String>(), new C<>());

        }

        ---

        Error:

        public static C<String> doesNotCompile = firstNonNull(new C<String>(), new C<>());
                                                             ^
            inferred: C<? extends Object>
            upper bound(s): C<String>,Object

        ---

        This is a regression -- it compiles correctly with the initial release of JDK 8.

        Reported on Stack Overflow: http://stackoverflow.com/questions/25490581

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  mcimadamore Maurizio Cimadamore
                  Reporter:
                  dlsmith Dan Smith
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: