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

The default constructor should be annotated with @Generated

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.5.6
    • 3.0.0-beta-1, 2.5.7
    • Compiler
    • None

    Description

      Groovy input:

      class GroovyDelegateClassTarget {
          @groovy.lang.Delegate
          Date target
      }
      

      Groovy output:

      public class GroovyDelegateClassTarget implements GroovyObject, Serializable, Cloneable, Comparable {
          @Delegate
          private Date target;
      
          public GroovyDelegateClassTarget() {
              CallSite[] var1 = $getCallSiteArray();
              super();
              MetaClass var2 = this.$getStaticMetaClass();
              this.metaClass = var2;
          }
      
          @Generated
          public long getTime() {
              CallSite[] var1 = $getCallSiteArray();
              return DefaultTypeTransformation.longUnbox(var1[0].call(this.target));
          }
      
          @Generated
          public void setTime(long param0) {
              CallSite[] var3 = $getCallSiteArray();
              var3[1].call(this.target, param0);
          }
      
          @Generated
          public boolean before(Date param0) {
              CallSite[] var2 = $getCallSiteArray();
              return DefaultTypeTransformation.booleanUnbox(var2[2].call(this.target, param0));
          }
      
          @Generated
          public boolean after(Date param0) {
              CallSite[] var2 = $getCallSiteArray();
              return DefaultTypeTransformation.booleanUnbox(var2[3].call(this.target, param0));
          }
      
          @Generated
          public int compareTo(Date param0) {
              CallSite[] var2 = $getCallSiteArray();
              return DefaultTypeTransformation.intUnbox(var2[4].call(this.target, param0));
          }
      
          @Generated
          public Instant toInstant() {
              CallSite[] var1 = $getCallSiteArray();
              return (Instant)ScriptBytecodeAdapter.castToType(var1[5].call(this.target), Instant.class);
          }
      
          @Generated
          public Date getTarget() {
              return this.target;
          }
      
          @Generated
          public void setTarget(Date var1) {
              this.target = var1;
          }
      }
      

      The constructor for this class should be annotated with @Generated

      Issue found during Hackergarten Zurich.

      Attachments

        Activity

          paulk Paul King added a comment - - edited

          This isn't really specific to @Delegate. @Delegate doesn't add any constructor itself but relies on the normal default constructor creation which currently doesn't add @Generated. It looks like Verifier#addDefaultConstructor doesn't call markAsGenerated. I'll update the summary.

          paulk Paul King added a comment - - edited This isn't really specific to @Delegate . @Delegate doesn't add any constructor itself but relies on the normal default constructor creation which currently doesn't add @Generated . It looks like Verifier#addDefaultConstructor doesn't call markAsGenerated . I'll update the summary.
          paulk Paul King added a comment -

          Fixed. Thanks for spotting the issue.

          paulk Paul King added a comment - Fixed. Thanks for spotting the issue.

          People

            paulk Paul King
            jwloka Jan Wloka
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: