generic enclosing type in cast: allowed?

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 7
    • Affects Version/s: 5.0
    • Component/s: 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.

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: