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

generic enclosing type in cast: allowed?

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 7
    • 5.0
    • specification
    • None
    • rc
    • generic
    • solaris_8
    • Verified

      Date: Sat, 06 Sep 2003 01:13:26 +0100
      From: Russel Winder <###@###.###>
      Subject: Incongruous or just a misunderstanding?
      To: Neal M Gafter <###@###.###>
      Cc: Graham Roberts <###@###.###>

      I have a generic type DLList which is a double linked list. As an inner
      class there is Iterator. I find that the compile lets me use
      DLList<Pair<K, V>>.Iterator as a type name in a declaration but not as a
      type name in a cast. So

      DLList<Pair<K, V>>.Iterator i = (DLList<Pair<K, V>>.Iterator)X.iterator();

      fails because the cast syntax is not acceptable but then that means
      that:

      DLList<Pair<K, V>>.Iterator i = (DLList.Iterator)X.iterator() ;

      fails because there is an unchecked assignment. A priori I would have
      thought the same type names could be used in both places.

            abuckley Alex Buckley
            gafter Neal Gafter (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: