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

compiler report error when using @Delegate to implement an interface

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.6-rc-2
    • 1.6.4, 1.7-beta-1
    • Compiler
    • None

    Description

      take the following example:

      // parent interface
      interface Foo{
       def foo();
      }
      
      // parent implementation - it's irrelevant
      class FooImpl implements Foo{
       def foo(){ println 'this is a foo impl' }
      }
      
      // child interface
      interface Bar extends Foo{
       def bar();
      }
      
      // child implementation
      class BarImpl implements Bar{
       @Delegate Foo foo;
       
       BarImpl(Foo f){ this.foo = f}
       
       def bar(){ println 'this is a bar impl'}
       
       //BarImpl doesn't implement foo() and it throws an exception
      }
      
      new BarImpl(new FooImpl()).bar()
      

      reported the following error

      Can't have an abstract method in a non-abstract class. The class 'BarImpl' must be declared abstract or the method 'java.lang.Object foo()' must be implemented.
      

      refer to the following discussion
      http://www.nabble.com/using-%40Delegate-to-implement-an-interface-td21308619.html#a21308619

      Attachments

        Activity

          People

            paulk Paul King
            mingfai Mingfai Ma
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: