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

Set coercion doesn't "pull through" method resolution

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 4.0.6
    • None
    • Static Type Checker
    • None

    Description

      In the usual case, the brackets syntax for an inline collection is implemented as an ArrayList but can become LinkedHashSet if the expression type is determined to be Set. However, this doesn't work if .asImmutable() is applied, because the expression is definitively identified as List first.

      Set<String> WORKS = ["a"]
      Set<String> ALSO_WORKS = (["b"] as Set).asImmutable()
      Set<String> FAILS = ["c"].asImmutable()
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            chrylis Christopher Smith
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: