You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Leonard Brünings (Jira)" <ji...@apache.org> on 2022/04/28 13:33:00 UTC

[jira] [Created] (GROOVY-10604) Changed behavior of DELEGATE_FIRST and static constants with Groovy 4

Leonard Brünings created GROOVY-10604:
-----------------------------------------

             Summary: Changed behavior of DELEGATE_FIRST and static constants with Groovy 4
                 Key: GROOVY-10604
                 URL: https://issues.apache.org/jira/browse/GROOVY-10604
             Project: Groovy
          Issue Type: Bug
    Affects Versions: 4.0.2, 4.0.1
            Reporter: Leonard Brünings


{code:groovy}
import spock.lang.*


class Reproducer extends Specification {
    public static final STATIC_VALUE = "Foo"
    
    def "problematic" () {
        given:
            def sut = new JooqRow(backing: [a: 'some', b:'Foo'])
        expect:
            with(sut) {
                a == 'some'
                b == STATIC_VALUE
            }
    }
}

class JooqRow {
    private Map<String, String> backing = [:]
    Object get(String name) {
        if (!backing.containsKey(name)) {
            throw new IllegalArgumentException("$name not contained in this result")
        } 
        return backing[name]
    }
}
{code}
([Groovy Web Console|https://gwc-experiment.appspot.com/?g=groovy_4_0&codez=eJxlUV1vgjAUfedX3JEl4GL8AWQuMYtL3EeWqNuLIUspF-wsLWsv6rL431cQFLf7UAo95_ScgyhKbQhsqflmJJnKRzee53HJrIU5lkanFUcDuCdUqYVFiVxkgjMSWsGPB27KKpGCgyX3kUMmFJOwWE6Ws_uP98nz2xTG4D9o7TfgZkkxA99pJxKLmuRDOGjF6snFFlV0eu0YtiInpXAHj1p_zfUuTBjfCJVHsGIRBFYXGAwhiQJ3WxAPTgK4d67pUnAnaB06xf693TAYj1u5f2dJfdZPd4E4eMf10FXYOu2aMmLLCOGFlbcLMs76EI7PO2izuISrKG7Qr8mnsw05UngEgWIF9g2LDMKrljjiWhETyj7hd9gA_0ajtXFO6v5mUmLO5MTkVYGKpnuOZf1DQ_-6ZoLSBK0cpiCUowoLBm0lyT_3eoDT1iBVRnUhVrVKfO6i7-IXccavEQ])

This example works in Groovy 2.5.x and 3.x but fails with 4.x, is this an intended change?



--
This message was sent by Atlassian Jira
(v8.20.7#820007)