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

Fail to identify updates on final variables declared in default methods

    XMLWordPrintableJSON

Details

    Description

      I have the following ill-typed program:

      interface Test {
        default void test() {
          final int x = 1;
          x = 2;
        } 
      }
      

      Actual behavior

      The code compiles successfully

      Expected behavior

      Code rejected with:

      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      test.groovy: 4: The variable [x] is declared final but is reassigned
      . At [4:5]  @ line 4, column 5.
             x = 2;
             ^
      
      1 error
      

      Tested against master (commit: 3cd76364f772250324f5729ef93ffd76fbdd2b79)

      Attachments

        Activity

          People

            paulk Paul King
            theosot Thodoris Sotiropoulos
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: