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

STC: no error for incorrect parameter type if not referenced in lambda

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 4.0.0-rc-1
    • None
    • None

    Description

      Follow up to GROOVY-9790. If a lambda expression does not reference one of its parameters, no inferred type metadata is written to the parameter and the boostrap error can still occur.

      Consider the following:

                  @groovy.transform.CompileStatic
                  void test1() {
                      java.util.stream.IntStream.range(0, 2).forEach(
                          (Integer i) -> {  } // no reference to "i"
                      )
                  }
                  @groovy.transform.CompileStatic
                  void test2() {
                      java.util.stream.IntStream.range(0, 2).forEach(
                          (String s) -> { assert false } // no reference to "s"
                      )
                  }
      

      9790 fixes depend of the inferred type of a variable expression being written back to accessed variable (the parameter).

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: