[ 
https://issues.apache.org/jira/browse/GROOVY-9665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17166502#comment-17166502
 ] 

Eric Milles commented on GROOVY-9665:
-------------------------------------

I ran a little experiment:
{code:groovy}
import spock.lang.*

final class Groovy9665 extends Specification {

  static final int NUM = 123

  @IgnoreIf({
    println getResolveStrategy() // "3"
    println getDelegate() // 
"org.spockframework.runtime.extension.builtin.PreconditionContext@..."
    println getOwner() // "null"
    println Groovy9665.NUM "123"
    false
  })
  def 'conditional test'() {
   given:
    def obj = new Object()
   expect:
    obj != null
  }
}
{code}

When the closure of {{@IgnoreIf}} or {{@Requires}} is executed, the delegate is 
a {{PreconditionContext}}, the owner is {{null}} and the resolve strategy is 
{{DELEGATE_ONLY}}.

To properly resolve static properties of the enclosing type, a static qualifier 
is required -- in this case "Groovy9665.NUM".  Previously there was checking at 
classgen time for static outer properties and it was performed for normal and 
within-closure cases equally.  It was dropped for the within-closure case 
because of the conflict with the closure's defined resolve strategy.

> Regression in 3.0.5 for accessing static constants in closures
> --------------------------------------------------------------
>
>                 Key: GROOVY-9665
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9665
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.5
>            Reporter: Björn Kautler
>            Assignee: Eric Milles
>            Priority: Major
>         Attachments: image-2020-07-28-00-00-37-055.png
>
>
> Up to 3.0.4 (including 2.x) it worked perfectly fine.
> Starting with 3.0.5 it does not work anymore.
> !image-2020-07-28-00-00-37-055.png!
> This is one of the classes where this is happening:
> [https://github.com/Vampire/spock/blob/issue-1177/spock-specs/mock-integration/src/test/groovy/MockingIntegrationSpec.groovy]
> It works fine if I use Groovy 3.0.4 and it fails with a 
> {{MissingPropertyException}} as soon as I switcht to 3.0.5.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to