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

Variable type is not updated in operator assignment

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.5.8
    • None
    • Static Type Checker
    • None

    Description

      class A { B plus(x) { new B() } }
      class B { def foo() {42} }
      
      @groovy.transform.CompileStatic
      def cs() {
          def var
          var = new A()
          var = var + 1
          var.foo()
      }
      
      assert cs() == 42
      
      @groovy.transform.CompileStatic
      def cs2() {
          def var
          var = new A()
          var += 1 
          var.foo() // Cannot find matching method A#foo()
      }
      
      assert cs2() == 42
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            daniilo Daniil Ovchinnikov
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: