-
Notifications
You must be signed in to change notification settings - Fork 480
Closed
Labels
Description
Issue description
Valid Groovy class cannot be compiled (worked fine before upgrade) because a final variable is seen as possibly not initialized in the cleanup block.
How to reproduce
Attempt to compile this spec:
import spock.lang.Specification
class Broken3 extends Specification {
def "test"() {
final value = 'hello'
expect:
value.size() > 3
cleanup:
clean value
}
def clean(v) {}
}
Run:
./gradlew compileTestGroovy
Error:
> Task :compileTestGroovy FAILED
startup failed:
/Users/renato/programming/projects/spock-tests/src/test/groovy/Broken3.groovy: 11: The variable [value] may be uninitialized
. At [11:15] @ line 11, column 15.
clean value
^
Expected outcome
Should compile ok.
Additional Environment information
From ./gradlew --version:
------------------------------------------------------------
Gradle 5.2.1
------------------------------------------------------------
Build time: 2019-02-08 19:00:10 UTC
Revision: f02764e074c32ee8851a4e1877dd1fea8ffb7183
Kotlin DSL: 1.1.3
Kotlin: 1.3.20
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_181 (Azul Systems, Inc. 25.181-b02)
OS: Mac OS X 10.14.6 x86_64
Also attempted with Oracle's JVM and the result is the same:
JVM: 1.8.0_171 (Oracle Corporation 25.171-b11)
Groovy/Spock version
dependencies {
compile 'org.spockframework:spock-core:1.3-groovy-2.5'
}
Reactions are currently unavailable