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

@Delegate to object by Class which implementing trait with fields complains 'abstract method in a non-abstract class'

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3.6
    • 3.0.11, 4.0.2
    • Compiler

    Description

      Please look at short reproduce:

      import groovy.transform.TupleConstructor
      
      trait Some{
          String STATIC = 'static data' // Commenting it out make it work (it have no difference static it or not)
      
          String so(){
              println ('STATIC=' + STATIC)
          }
      }
      
      class Delegator implements Some{
          String delegated(){
              println 'delegated work'
          }
      }
      
      class SomeClass{
          @Delegate Delegator delegator = new Delegator();
      }
      
      def s = new SomeClass()
      s.delegated()
      

      Running it I have:

      2 compilation errors:
      
      Can't have an abstract method in a non-abstract class. The class 'SomeClass' must be declared abstract or the method 'java.lang.String Some__STATIC$get()' must be implemented.
       at line: 17, column: 1
      
      Can't have an abstract method in a non-abstract class. The class 'SomeClass' must be declared abstract or the method 'void Some__STATIC$set(java.lang.String)' must be implemented.
       at line: 17, column: 1
      

      Attachments

        Activity

          People

            emilles Eric Milles
            hubbitus Pavel Alexeev
            Votes:
            0 Vote for this issue
            Watchers:
            3 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 - 20m
                20m