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

Regression for accessing private static constants in closures from Parent Classes

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.14, 3.0.6
    • Component/s: None
    • Labels:
      None

      Description

      The following code worked in 2.5.12, in 2.5.13 testChildClass fails with groovy.lang.MissingPropertyException: No such property: PATTERNS for class: Child

      Eric Milles probably related to the changes mentioned here GROOVY-9665

      class Example {
      
          @Test
          void testBaseClass() {
              new Base().check("FooSpec")
          }
      
          @Test
          void testChildClass() {
              new Child().check("FooSpec")
          }
      
      }
      
      class Base {
          private static final List<Pattern> PATTERNS = [~/.*Test/, ~/.*Spec/]
      
          def check(String str) {
              List failures = []
      
              def result = PATTERNS.findResult { Pattern pattern ->
                  if (pattern.matcher(str).matches()) {
                      return str
                  } else {
                      failures.add("Pattern ${PATTERNS.indexOf(pattern)} did not match")
                  }
              }
              if (!result) {
                  throw new IllegalArgumentException("Did Match no pattern: "+failures.join(", "))
              }
      
              return result
          }
      }
      
      class Child extends Base {
      
      }
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                emilles Eric Milles
                Reporter:
                leonard84 Leonard Brünings
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: