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

@NamedVariant processing error

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.5.1
    • Component/s: Compiler
    • Labels:
      None

      Description

      Example about @NamedVariant from http://groovy-lang.org/releasenotes/groovy-2.5.html works perfectly well as far as all @NamedDelegate type are compiling in the same compilation unit.

      class Animal {
          String type, name
      }
      
      @ToString(includeNames=true)
      class Color {
          Integer r, g, b
      }
      
      @NamedVariant
      String foo(String s1, @NamedParam String s2,
                 @NamedDelegate Color shade,
                 @NamedDelegate Animal pet) {
          "$s1 $s2 ${pet.type?.toUpperCase()}:$pet.name $shade"
      }
      
      

      But let's modify this example. If you have Animal an Color classes compiled beforehand and passed to the compiler with classpath, you will receive 'Error during @NamedVariant processing. Duplicate property 'metaClass' found.'

      NamedVariantASTTransformation treats 'setMetaClass' method as set method of some property with ''metaClass' name. Obviously these names are clashed at compile time.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                paulk Paul King
                Reporter:
                Alexey Afanasiev Alexey Afanasiev
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: