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

traits: add support for static property notation in static contexts

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

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • None
    • None
    • None

    Description

      Bean-style references to static trait property in static scopes fail with unresolved variable errors.

      This works:

      trait T {
        static p = 1
      }
      class C implements T {
        static m() {
          setP(2)
          setP(getP() + 1)
          return getP()
        }
      }
      C.m()​
      

      This fails:

      trait T {
        static p = 1
      }
      class C implements T {
        static m() {
          p = 2 // Apparent variable 'p' was found in a static scope but doesn't refer to a local variable, static field or class
          p += 1
          return p
        }
      }
      C.m()​
      

      Attachments

        Activity

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

          People

            Unassigned Unassigned
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment