[
https://issues.apache.org/jira/browse/GROOVY-9692?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Mykola Golubyev updated GROOVY-9692:
------------------------------------
Description:
Custom extension like this
{code:java}
class CustomExtension {
static MyData call(ArrayList header, Closure code) {
new MyData(data: header.join(":") + " " + code())
}
static MyData test(ArrayList header, Closure code) {
new MyData(data: header.join(":") + " " + code())
}
}
{code}
used to work with Groovy 2.5.12
{code:java}
class CustomExtensionTest {
@Test
void "implicit call on array with closure used to work"() {
def result = [1, 2, 3] {
"world"
}
assert result.data == '1:2:3 world'
}
@Test
void "explicit call on array with closure still works"() {
def result = [1, 2, 3].test {
"world"
}
assert result.data == '1:2:3 world'
}
}
{code}
with Groovy 3.0.x I get this error instead
{code:java}
groovy.lang.MissingMethodException: No signature of method:
regression.CustomExtensionTest.[1, 2, 3]() is applicable for argument types:
(regression.CustomExtensionTest$_call_on_array_with_closure_used_to_work_closure1)
values:
[regression.CustomExtensionTest$_call_on_array_with_closure_used_to_work_closure1@8b87145]
{code}
Is this intentional?
I have attached a maven project to reproduce.
was:
Custom extension like this
{code:java}
class CustomExtension {
static MyData call(ArrayList header, Closure code) {
new MyData(data: header.join(":") + " " + code())
}
static MyData test(ArrayList header, Closure code) {
new MyData(data: header.join(":") + " " + code())
}
}
{code}
used to work with Groovy 2.5.12
{code:java}
class CustomExtensionTest {
@Test
void "implicit call on array with closure used to work"() {
def result = [1, 2, 3] {
"world"
}
assert result.data == '1:2:3 world'
}
@Test
void "explicit call on array with closure still works"() {
def result = [1, 2, 3].test {
"world"
}
assert result.data == '1:2:3 world'
}
}
{code}
with Groovy 3.0.x I get this error instead
{code:java}
groovy.lang.MissingMethodException: No signature of method:
regression.CustomExtensionTest.[1, 2, 3]() is applicable for argument types:
(regression.CustomExtensionTest$_call_on_array_with_closure_used_to_work_closure1)
values:
[regression.CustomExtensionTest$_call_on_array_with_closure_used_to_work_closure1@8b87145]
{code}
Is this intentional?
I have attached a maven project to reproduce.
> Adding extension method 'call' on ArrayList with Closure as a parameter
> stopped working in 3.0.x
> ------------------------------------------------------------------------------------------------
>
> Key: GROOVY-9692
> URL: https://issues.apache.org/jira/browse/GROOVY-9692
> Project: Groovy
> Issue Type: Bug
> Components: parser
> Affects Versions: 3.0.5
> Reporter: Mykola Golubyev
> Priority: Major
> Attachments: groovy3-call-regression.zip
>
>
> Custom extension like this
> {code:java}
> class CustomExtension {
> static MyData call(ArrayList header, Closure code) {
> new MyData(data: header.join(":") + " " + code())
> }
> static MyData test(ArrayList header, Closure code) {
> new MyData(data: header.join(":") + " " + code())
> }
> }
> {code}
> used to work with Groovy 2.5.12
> {code:java}
> class CustomExtensionTest {
> @Test
> void "implicit call on array with closure used to work"() {
> def result = [1, 2, 3] {
> "world"
> }
> assert result.data == '1:2:3 world'
> }
> @Test
> void "explicit call on array with closure still works"() {
> def result = [1, 2, 3].test {
> "world"
> }
> assert result.data == '1:2:3 world'
> }
> }
> {code}
> with Groovy 3.0.x I get this error instead
> {code:java}
> groovy.lang.MissingMethodException: No signature of method:
> regression.CustomExtensionTest.[1, 2, 3]() is applicable for argument types:
> (regression.CustomExtensionTest$_call_on_array_with_closure_used_to_work_closure1)
> values:
> [regression.CustomExtensionTest$_call_on_array_with_closure_used_to_work_closure1@8b87145]
> {code}
> Is this intentional?
> I have attached a maven project to reproduce.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)