[
https://issues.apache.org/jira/browse/GROOVY-9759?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Paul King updated GROOVY-9759:
------------------------------
Description:
This is a follow-on from GROOVY-9695.
The following code works in 3.0.4 but fails with a STC error in 3.0.5:
{code:groovy}
@groovy.transform.CompileStatic
class Foo {
private static final Integer ANSWER = 42
def checkMap() {
Map failures = [:]
def closure = {
assert ANSWER.longValue() == 42L // OKAY
failures[ANSWER.longValue()] = 1 // <== STC error here
}
closure()
failures
}
}
assert new Foo().checkMap() == [42L:1]
{code}
{noformat}
[Static type checking] - Cannot find matching method
java.lang.Object#longValue()
{noformat}
was:
This is a follow-on from GROOVY-9695.
The following code works in 3.0.4 but fails with a STC error in 3.0.5:
{code:groovy}
@groovy.transform.CompileStatic
class Foo {
private static final Integer ANSWER = 42
def checkMap() {
Map failures = [:]
def closure = {
assert ANSWER.longValue() == 42L
failures[ANSWER.longValue()] = 1
}
closure()
failures
}
}
assert new Foo().checkMap() == [42L:1]
{code}
{noformat}
[Static type checking] - Cannot find matching method
java.lang.Object#longValue()
{noformat}
> CLONE - Regression for accessing private static constants in closures from Map
> ------------------------------------------------------------------------------
>
> Key: GROOVY-9759
> URL: https://issues.apache.org/jira/browse/GROOVY-9759
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 3.0.5
> Reporter: Leonard Brünings
> Priority: Major
>
> This is a follow-on from GROOVY-9695.
> The following code works in 3.0.4 but fails with a STC error in 3.0.5:
> {code:groovy}
> @groovy.transform.CompileStatic
> class Foo {
> private static final Integer ANSWER = 42
> def checkMap() {
> Map failures = [:]
> def closure = {
> assert ANSWER.longValue() == 42L // OKAY
> failures[ANSWER.longValue()] = 1 // <== STC error here
> }
> closure()
> failures
> }
> }
> assert new Foo().checkMap() == [42L:1]
> {code}
> {noformat}
> [Static type checking] - Cannot find matching method
> java.lang.Object#longValue()
> {noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)