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

Inference ignores capture variable as upper bound

    Details

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

      Backports

        Description

        This produces an unexpected error:

          class C<T> {}
          <X> void m(C<? super X> arg) {}
          void test(C<?> arg) {
            m(arg);
          }

        error: method m in class cannot be applied to given types;
            m(arg);
            ^
          required: C<? super X>
          found: C<CAP#1>
          reason: cannot infer type-variable(s) X
            (argument mismatch; C<CAP#1> cannot be converted to C<? super X>)
          where X is a type-variable:
            X extends Object declared in method <X>m(C<? super X>)
          where CAP#1 is a fresh type-variable:
            CAP#1 extends Object from capture of ?
        1 error

        The error is the same under both -source 8 and -source 7.

        This is a regression: there is also an error in javac 7, but not javac 6.

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved: