Describe the bug
Making a reference to the spec's field or property using explicit-this in the then block produces an STC error. No error shows for this.myField in the when block.
this.myField in the then is written as $spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), this).myField in the feature method. record returns Object, so as far as STC is concerned, it can't find the property "myField" in java.lang.Object.
Spock 2.4
Groovy 5.0.5
To Reproduce
@groovy.transform.TypeChecked
class SomeSpec extends Specification {
String myField
void testField() {
when:
this.myField = 'test'
then:
this.myField == 'test' // [Static type checking] - No such property: myField for class: java.lang.Object
}
}
Expected behavior
this.myField checks properly or is exempted from STC in when, then, expect, etc.
Actual behavior
"[Static type checking] - No such property: myField for class: java.lang.Object"
Java version
Java 25.0.2
Buildtool version
Eclipse 2026-06 / Groovy 5.0.5
What operating system are you using
Windows
Describe the bug
Making a reference to the spec's field or property using explicit-this in the
thenblock produces an STC error. No error shows forthis.myFieldin thewhenblock.this.myFieldin the then is written as$spock_valueRecorder.record($spock_valueRecorder.startRecordingValue(0), this).myFieldin the feature method.recordreturns Object, so as far as STC is concerned, it can't find the property "myField" in java.lang.Object.Spock 2.4
Groovy 5.0.5
To Reproduce
Expected behavior
this.myFieldchecks properly or is exempted from STC inwhen,then,expect, etc.Actual behavior
"[Static type checking] - No such property: myField for class: java.lang.Object"
Java version
Java 25.0.2
Buildtool version
Eclipse 2026-06 / Groovy 5.0.5
What operating system are you using
Windows