Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Power assertion broken for non-static inner class after upgrade to Groovy 3.0.8 #1318

Closed
szpak opened this issue Apr 30, 2021 · 3 comments · Fixed by #1319
Closed

Power assertion broken for non-static inner class after upgrade to Groovy 3.0.8 #1318

szpak opened this issue Apr 30, 2021 · 3 comments · Fixed by #1319
Labels

Comments

@szpak
Copy link
Member

szpak commented Apr 30, 2021

Issue description

Power assertion has broken for non-static inner class after upgrade to Groovy 3.0.8.

How to reproduce

class PowerAssertionRegressionGroovy380Spec extends Specification {

  def test() {
    expect:
    new NonStaticInnerClass() == null
  }

  class NonStaticInnerClass {
    String toString() { "nsi" }
  }

}

fails wtih Groovy 3.0.7 with:

Condition not satisfied:

new NonStaticInnerClass() == null
|                         |
nsi                       false

Expected :null
Actual   :

With Groovy 3.0.8 there is:

Condition not satisfied:

new NonStaticInnerClass() == null
                          |
                          null

Expected :
Actual   :

The same assertion with plain Groovy (without Spock) works fine.

Additional Environment information

Spock master, Groovy 3.0.8

Additional information

The test for that case was added in autumn 2020 in #930.

Sample failure: https://github.com/spockframework/spock/pull/1316/checks?check_run_id=2475170792#step:6:130

@leonard84
Copy link
Member

@Vampire would you take a look, as you did the original fix.

From what I can see is that the check expr == THIS_EXPRESSION in
for (Expression expr : expressions) converted.add(expr == THIS_EXPRESSION ? (T) expr : convert(expr));
does not match anymore, since the expr instance of this is different from the constant.

grafik

@paulk-asert do you know of any changes in groovy that might cause this?

@leonard84
Copy link
Member

I think apache/groovy#1531 is the culprit, we will have to update the implicit this check.

@Vampire
Copy link
Member

Vampire commented May 2, 2021

Yes, you are totally right.
See PR #1319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants