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

@Delegate breaks use of Generics

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7-beta-1
    • 1.6.5, 1.7-beta-2
    • None
    • None

    Description

      @Delegate seems to breaking the use of generics a bit.

      This script goes through:

      GroovyClassLoader gcl = new GroovyClassLoader()
      
      gcl.parseClass """
          class A {
              List a
          }
      """
      
      gcl.parseClass """
          class B {
              List<String> a
          }
      """
      

      This script fails:

      GroovyClassLoader gcl = new GroovyClassLoader()
      
      gcl.parseClass """
          class A {
              @Delegate List a // use of @Delegate List affects use of List<String> later
          }
      """
      
      gcl.parseClass """
          class B {
              List<String> a
          }
      """
      

      with the error

      script1253728549265.groovy: 3: The class java.util.List refers to the class java.util.List and uses 1 parameters, but the referred class takes no parameters
      

      It seem to be happening because DelegateASTTransformation#nonGeneric(ClassNode) seems to be clearing the generics information from the ClassNodes statically loaded by org.codehaus.groovy.ast.ClassHelper

      Attachments

        Activity

          People

            roshandawrani Roshan Dawrani
            roshandawrani Roshan Dawrani
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: