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

Assignment chain fails when using @CompileStatic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Critical
    • Resolution: Fixed
    • 2.3.3, 2.4.0-beta-1
    • 2.4.0-beta-4
    • Static compilation
    • None

    Description

      Consider the following Java class:

      package b;
      
      import java.util.concurrent.Callable;
      
      public class B {
      	private String name;
      
      	public B(final String name) {
      		this.name = name;
      	}
      	
        public void setCallable(final Callable<String> c) {
      	  System.out.println(name + ": " + String.valueOf(c));
        }
      }
      

      and the following Groovy class:

      @CompileStatic
      class Test {
      
      	static main(args) {
      		def clos = { 'bar' } as Callable<String>
      		B b1 = new B('b1')
      		B b2 = new B('b2')
      		b1.callable = b2.callable = clos
      	}
      }
      

      Run Test class as a Groovy script: b1.callable is assigned null, instead of the clos closure. Remove the @CompileStatic in Test, re-run and... all goes right!

      Attachments

        Activity

          People

            melix C├ędric Champeau
            mauromol Mauro Molinari
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: