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

STC LUB of List and Set is not Collection for Java 21

    XMLWordPrintableJSON

Details

    Description

      The new SequencedCollection interface introduced in Java 21 has altered the type inference results for mixed use of List and Set. Consider the following:

      def x
      x = [] as List
      if (predicate()) {
        x = [] as Set
      }
      x
      

      Under STC, the inferred type of the last occurrence of "x" has changed from Collection to Object.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: