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

Problem With Stubs Related To Class Which Implements A Trait

    XMLWordPrintableJSON

    Details

      Description

      The attached traitinheritance.zip file contains the following code:

      src/main/groovy/demo/DemoTrait.groovy
      package demo
      
      trait DemoTrait {
      
          int getMagicNumber() {
              42
          }
      }
      
      src/main/groovy/demo/DemoClass.groovy
      package demo
      
      class DemoClass implements DemoTrait {}
      

      All of that compiles as expected. If I add this class compilation fails:

      src/main/groovy/demo/DemoSubClass.java
      package demo;
      
      public class DemoSubClass extends DemoClass {}
      

      Note that the compilation error message doesn't mention the newly created subclass. It mentions the class that previously compiled without error.

      $ ./gradlew clean cG
      :clean
      :compileJava UP-TO-DATE
      :compileGroovy
      /Users/jeff/traitinheritance/build/tmp/groovy-java-stubs/demo/DemoClass.java:10: error: DemoClass is not abstract and does not override abstract method getMagicNumber() in DemoTrait
      public class DemoClass
             ^
      1 error
      startup failed:
      Compilation failed; see the compiler error output for details.
      
      1 error
      
      :compileGroovy FAILED
      
      FAILURE: Build failed with an exception.
      
      * What went wrong:
      Execution failed for task ':compileGroovy'.
      > 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: 4.378 secs
      

        Attachments

        1. traitinheritance.zip
          50 kB
          Jeff Brown

          Activity

            People

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              brownj Jeff Brown
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: