If this snippet, "this" will always refer to the enclosing class, never the
delegate "list" or the owner (which may be the enclosing closure or "this" if
no enclosing closure). That is, the choice of "this" has already frozen where
"contains" can come from.
with(list) {
SpockRuntime.verifyMethodCondition(this, "contains", [1])
}
From: Leonard Brünings [mailto:[email protected]]
Sent: Monday, November 20, 2017 5:52 PM
To: [email protected]
Subject: Re: Get reference to enclosing closure
Spock doesn't rewrite it to `this.getThisObject()`.
This is what Spock does
with(list) {
SpockRuntime.verifyMethodCondition(this, "contains", [1])
}
The transformation from `this` to `this.getThisObject()` is done by groovy at a
later stage.
My guess somewhere in the AST-to-Bytecode ASM code as I can see the upper
version in the
last stage of the AST-Transforms.
with(list) {
SpockRuntime.verifyMethodCondition(this.getThisObject(), "contains", [1])
}
Am 20.11.2017 um 22:09 schrieb
[email protected]<mailto:[email protected]>:
When you rewrite to this form:
with(list) {
SpockRuntime.verifyMethodCondition(this.getThisObject(), "contains", [1])
}
You've esentially frozen your choice of delegate, owner or this. The dynamic
resolution of "implicit this" to one of those is no longer going to happen. I
guess you'd need to re-implement the resolution strategy.