Groovy
  1. Groovy
  2. GROOVY-4967

List to LinkedHashSet inconsistent conversion behavior vs List to HashSet

    Details

    • Type: Bug Bug
    • Status: 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

      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

        Mark Thomas made changes -
        Workflow jira [ 12971437 ] Default workflow, editable Closed status [ 12979255 ]
        Mark Thomas made changes -
        Project Import Mon Apr 06 02:11:23 UTC 2015 [ 1428286283443 ]
        Mark Thomas made changes -
        Workflow jira [ 12733893 ] Default workflow, editable Closed status [ 12745703 ]
        Mark Thomas made changes -
        Project Import Sun Apr 05 13:32:57 UTC 2015 [ 1428240777691 ]
        Paul King made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Roshan Dawrani made changes -
        Fix Version/s 1.8.5 [ 18071 ]
        Fix Version/s 2.0-beta-2 [ 18072 ]
        Resolution Fixed [ 1 ]
        Status Open [ 1 ] Resolved [ 5 ]
        Roshan Dawrani made changes -
        Assignee Roshan Dawrani [ roshandawrani ]
        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 created issue -

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development