Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4967

List to LinkedHashSet inconsistent conversion behavior vs List to HashSet

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 1.8.5, 2.0-beta-2
    • None
    • 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
      

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            roshandawrani Roshan Dawrani
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: