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

generics: failing regression test

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 5.0
    • 5.0
    • tools
    • tiger
    • generic
    • solaris_8

    Description

      regression test test/tools/generics/odersky/Test.java
      fails

      Test.java:39: inconvertible types
      found : List<java.lang.Object>
      required: List<java.lang.String>
              a = (List<String>) nil();
                                    ^
      1 error



      class Test {

          static <B> List<B> nil() { return new List<B>(); }
          static <A> List<A> cons(A x, List<A> xs) { return xs.prepend(x); }
          static <A> Cell<A> makeCell(A x) { return new Cell<A>(x); }
          static <A> A id(A x) { return x; }

          public static void main(String[] args) {
              List<String> xs = nil();
              List<String> ys = cons("abc", nil());
              List<String> zs = nil().prepend("abc");

              System.out.println(nil());
              System.out.println(nil().length());

              System.out.println(cons("abc", nil()));
              System.out.println(nil().prepend("abc"));
              System.out.println(nil().prepend(makeCell(null)));
              System.out.println(cons(makeCell(null), nil()));

              System.out.println(id(nil()));
              System.out.println(id(nil()).length());

              System.out.println(cons("abc", id(nil())));
              System.out.println(id(nil()).prepend("abc"));
              System.out.println(id(nil()).prepend(makeCell(null)));
              System.out.println(cons(makeCell(null), id(nil())));

              List<String> a = args.length == 1 ? nil() : nil();
              a = (List<String>) nil();
          }

      }

      Attachments

        Activity

          People

            gafter Neal Gafter
            gafter Neal Gafter
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: