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

Object ranges should be inferred as Range<Object> for improved fluency

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.2
    • Fix Version/s: 2.3.0-beta-1, 2.2.3
    • Component/s: None
    • Labels:
      None

      Description

      The following code fails with master:

      static BigInteger iterative(final BigInteger n) {
          validateParameter(n)
          BigInteger total = 1G
          if (n > 1) { (2G..n).each{BigInteger i -> total *= i } }
          total
        }
      

      The reason is that the inferred type of the big integer range is not Range<BigInteger> but the concrete type ObjectRange. Unfortunately, this type is not generified in the Groovy codebase and can't be without breaking binary compatibility.

      As a workaround, the inferred type should be Range<BigInteger.

        Attachments

          Activity

            People

            • Assignee:
              melix Cédric Champeau
              Reporter:
              melix Cédric Champeau
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: