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

Problem With Static Trait Properties And Test Classes

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.8, 2.4.0-beta-4
    • 2.3.9, 2.4.0-rc-1
    • None
    • None

    Description

      The attached app contains the following code:

      src/demo/SomeTrait.groovy
      package demo
      
      trait SomeTrait {
          private static String someString
      }
      
      src/demo/SomeClass.groovy
      package demo
      
      class SomeClass implements SomeTrait {}
      
      test/demo/SomeTestClass.groovy
      package demo
      
      class SomeTestClass implements SomeTrait {}
      

      SomeClass.groovy will compile. SomeTestClass.groovy will not compile.

      $ ./gradlew clean cTG
      :clean
      :compileJava UP-TO-DATE
      :compileGroovy
      :processResources UP-TO-DATE
      :classes
      :compileTestJava UP-TO-DATE
      :compileTestGroovy
      startup failed:
      /Users/jeff/t/statictraitproperty/test/demo/SomeTestClass.groovy: -1: Method 'demo_SomeTrait__someString$get' is already defined in class 'demo.SomeTestClass'. You cannot have both a static and a non static method with the same signature
       @ line -1, column -1.
      /Users/jeff/t/statictraitproperty/test/demo/SomeTestClass.groovy: -1: Method 'demo_SomeTrait__someString$set' is already defined in class 'demo.SomeTestClass'. You cannot have both a static and a non static method with the same signature
       @ line -1, column -1.
      2 errors
      
      :compileTestGroovy FAILED
      
      FAILURE: Build failed with an exception.
      
      * What went wrong:
      Execution failed for task ':compileTestGroovy'.
      > Compilation failed; see the compiler error output for details.
      
      * Try:
      Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
      
      BUILD FAILED
      
      Total time: 3.841 secs
      

      If I edit build.gradle and change Groovy 2.3.8 to 2.3.7 the code will compile.

      Attachments

        1. statictraitproperty.zip
          50 kB
          Jeff Brown

        Activity

          People

            melix Cédric Champeau
            brownj Jeff Brown
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: