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

TraitComposer should mark generated methods as @Generated

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.5.14
    • 2.5.16, 3.0.10, 4.0.1
    • Compiler
    • None

    Description

      I have been marking Grails generated methods as Generated, but there are still open cases and those should be resolved in groovy. https://github.com/grails/grails-core/issues/11318
      In Grails with Controllers there is heavy use of Traits and

      org.codehaus.groovy.transform.trait.TraitComposer class doesn't mark all its generated methods as Generated.

      Example of trait composition:

              trait TraitA {
                  private String variableA
                  
                  @groovy.transform.Generated
                  String methodA() { "method" }
              }
      
              trait TraitB {
                  private String variableB
                  
                  @groovy.transform.Generated
                  String methodB() { "i'm method too" }
              }
      
              trait TraitComposeAB implements TraitA, TraitB {
                  
              }
      
              class ClassUnderTest implements TraitComposeAB {
                  
              }
      

      For ClassUnderTest the TraitComposer will add methods for traits variables:

      "public java.lang.String ClassUnderTest.TraitB__variableB$get()"
      "public java.lang.String ClassUnderTest.TraitA__variableA$get()"
      "public java.lang.String ClassUnderTest.TraitA__variableA$set(java.lang.String)"
      "public java.lang.String ClassUnderTest.TraitB__variableB$set(java.lang.String)"
      

      and for methods:

      "public java.lang.String ClassUnderTest.TraitAtrait$super$methodA()"
      "public java.lang.String ClassUnderTest.TraitBtrait$super$methodB()"
      

      Those methods I think should be marked as Generated.

      Will provide pull-request soon.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            paulk Paul King
            aulea Alar Aule
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 40m
                40m

                Slack

                  Issue deployment