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

inference: Failure of inference due to lci definition

XMLWordPrintable

    • rc
    • x86
    • windows_xp
    • Verified

      FULL PRODUCT VERSION :
      javac 1.6.0_01

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      The compiler fails to infer the obvious type for the method call, which has to be supplied as a hint.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Try to compile the code below.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      No compiler error.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
        Bug.java:5: <T>eval(T) in Bug cannot be applied to (Bug.Foo<capture#636 of ?,capture#203 of ?>)
              eval(foo); // fails
              ^
      1 error


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Bug {

          public static void test() {
              Foo<?, ?> foo = null;
              eval(foo); // fails
              Bug.<Foo<?, ?>>eval(foo);
          }

          public static <T extends Iterable<T>> void eval(T x) { }

          public static interface Foo<S, T> extends Iterable<Foo<?, ?>> { }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      See last line of test() method.

            abuckley Alex Buckley
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: