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

A class using the @Delegate annotation does not implement the delegate's interfaces from the Java side when join compiling

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.6, 1.8-beta-3, 2.4.0-rc-1
    • None
    • None

    Description

      A class using the @Delegate annotation does not implement the delegate's interfaces from the Java side when joint compiling. The workaround for this is using a cast. This is confusing when working on mixed java/groovy projects. When inspecting the generated class file, the class doing the delegation does indeed implement the correct interfaces so I'm guessing it has something to do with the stub generation.

      See the following example:

      //groovy code
      class DelegateWeirdness {
        @Delegate
        private Collection l = new ArrayList();
      }
      
      //java code
      public class DelegateWierdnessClient {
          Collection c = new DelegateWeirdness();
      }
      
      C:\IdeaProjects\groovy-bugs>groovyc -j src\main\groovy\DelegateWeirdness.groovy src\main\java\DelegateWierdnes
      sClient.java
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Compile error during compilation with javac.
      C:\IdeaProjects\groovy-bugs\src\main\java\DelegateWierdnessClient.java:4: incompatible types
      found   : DelegateWeirdness
      required: java.util.Collection
          Collection c = new DelegateWeirdness();
                         ^
      1 error
      
      
      1 error
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              leo.herbie Travis Schneeberger
              Votes:
              5 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated: