groovy
  1. groovy
  2. GROOVY-4967

List to LinkedHashSet inconsistent conversion behavior vs List to HashSet

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.8.5, 2.0-beta-2
    • Component/s: None
    • Labels:
      None
    • Number of attachments :
      0

      Description

      a), b), and c) all work, but d) fails with "GroovyCastException: Cannot cast object '[x]' with class 'java.util.ArrayList' to class 'java.util.LinkedHashSet'"

      a)

      List x = []
      HashSet<String> lhs = x
      

      b)

      List x = ['x']
      HashSet<String> lhs = x
      

      c)

      List x = []
      LinkedHashSet<String> lhs = x
      

      d)

      List x = ['x']
      LinkedHashSet<String> lhs = x
      

        Activity

        Roshan Dawrani made changes -
        Field Original Value New Value
        Description a), b), and c) all work, but d) fails with "GroovyCastException: Cannot cast object '[x]' with class 'java.util.ArrayList' to class 'java.util.LinkedHashSet'"

        a)
        {code}
        List x = []
        HashSet<String> lhs = x
        &#8203;{code}

        b)
        {code}
        List x = ['x']
        HashSet<String> lhs = x
        &#8203;{code}

        c)
        {code}
        List x = []
        LinkedHashSet<String> lhs = x
        &#8203;{code}

        d)
        {code}
        List x = ['x']
        LinkedHashSet<String> lhs = x
        &#8203;{code}
        a), b), and c) all work, but d) fails with "GroovyCastException: Cannot cast object '[x]' with class 'java.util.ArrayList' to class 'java.util.LinkedHashSet'"

        a)
        {code}
        List x = []
        HashSet<String> lhs = x
        {code}

        b)
        {code}
        List x = ['x']
        HashSet<String> lhs = x
        {code}

        c)
        {code}
        List x = []
        LinkedHashSet<String> lhs = x
        {code}

        d)
        {code}
        List x = ['x']
        LinkedHashSet<String> lhs = x
        {code}
        Roshan Dawrani made changes -
        Assignee Roshan Dawrani [ roshandawrani ]
        Roshan Dawrani made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0-beta-2 [ 18072 ]
        Fix Version/s 1.8.5 [ 18071 ]
        Resolution Fixed [ 1 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Roshan Dawrani
            Reporter:
            Roshan Dawrani
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: