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

@CompileStatic breaks assign in combination with dereferencing

    Details

      Description

      @CompileStatic breaks assignment for code like

      @groovy.transform.CompileStatic
      class StaticClass {
          StringHolder holder = new StringHolder()
          String str
      
          StaticClass(String s) {
              str = holder.str = s
          }
      }
      
      class StringHolder {
          String str
      }
      
      def s = new StaticClass('test')
      assert s.holder.str == 'test'
      assert s.str != 'test'
      

      The second assert fails because s.str == null. Without @CompileStatic it works correctly (and as java).

        Attachments

          Activity

            People

            • Assignee:
              daniel_sun Daniel Sun
              Reporter:
              flofreud Florian Freudenberg
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: