Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
This may be related to GROOVY-10294.
I have the following program
interface A { void a(); } class Test { void test_closure() { def a = (A) null; def x = { -> a = null; } a.a(); } }
Actual behaviour
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: test.groovy: 15: [Static type checking] - A closure shared variable [a] has been assigned with various types and the method [a()] does not exist in the lowest upper bound of those types: [java.lang.Object]. In general, this is a bad practice (variable reuse) because the compiler cannot determine safely what is the type of the variable at the moment of the call in a multithreaded context. @ line 15, column 5. a.a(); ^ 1 error
Expected behaviour
Compile successfully
Tested against master (https://github.com/apache/groovy/commit/0ff632514f9e06b8cea96f2e70749b3da3bc6dbb).