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

'this' and 'super' as LHS of an assignment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.4.8
    • None
    • None

    Description

      The following code runs successfully.

      class Foo {
        static void main(String[] args) {
          assert "${this.name} ${super.name}" == 'Foo java.lang.Object'
          super = true
          this = false
          assert "${this.name} ${super.name}" == 'Foo java.lang.Object'
        }
      }
      

      The attempt to change these 'special' variables is ignored but there should be some kind of error. I think it makes sense for this to be a compilation error and it should come late in the compilation phases to allow DSLs to include 'this' or 'super' and transform them into something sensible.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: