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

CLONE - Regression for accessing private static constants in closures from Map

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 3.0.5
    • None
    • None
    • None

    Description

      This is a follow-on from GROOVY-9695.
      The following code works in 3.0.4 but fails with a STC error in 3.0.5:

      @groovy.transform.CompileStatic
      class Foo {
          private static final Integer ANSWER = 42
      
          def checkMap() {
              Map failures = [:]
      
              def closure = {
                  assert ANSWER.longValue() == 42L // OKAY
                  failures[ANSWER.longValue()] = 1  // <== STC error here
              }
              closure()
              failures
          }
      }
      assert new Foo().checkMap() == [42L:1]
      
      [Static type checking] - Cannot find matching method java.lang.Object#longValue()
      

      Attachments

        Issue Links

          Activity

            People

              emilles Eric Milles
              leonard84 Leonard Brünings
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h
                  1h