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

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

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.4.8
    • Component/s: None
    • Labels:
      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

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

                Dates

                • Created:
                  Updated:
                  Resolved: