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

ASF GitHub Bot commented on GROOVY-8907:
----------------------------------------

GitHub user henriquelsmti opened a pull request:

    https://github.com/apache/groovy/pull/834

    GROOVY-8907: Correcting @ClosureParams to correct type

    https://issues.apache.org/jira/browse/GROOVY-8907

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/henriquelsmti/groovy GROOVY-8907_master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/834.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #834
    
----
commit 1eabcc213662fc1caba3a839c3ae5c10319b4256
Author: Henrique Mota <henriquebrasileiro@...>
Date:   2018-11-30T12:04:28Z

    Correcting @ClosureParams to correct type

----


> StringGroovyMethods.findAll(String, Pattern, Closure) and 
> StringGroovyMethods.findAll(CharSequence, Pattern, Closure) is with 
> @ClosureParams incorrect
> ------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-8907
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8907
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 3.x, 2.4.x, 2.5.x, 3.0.0-alpha-4, 2.6.0-alpha-5
>            Reporter: Henrique Mota
>            Priority: Minor
>         Attachments: image.png
>
>
> StringGroovyMethods.find(arg1, arg2, Closure) and  
> StringGroovyMethods.findAll(arg1, arg2, Closure) is with 
> @ClosureParams(value=SimpleType.class, options="java.lang.String[]") but the 
> Closure receive a instance of List<String> from 
> DefaultGroovyMethods.collect(matcher, closure), this cause a Exception
> {code:java}
> Caught: java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to 
> java.util.List
> java.lang.ClassCastException: [Ljava.lang.String; cannot be cast to 
> java.util.List
> at CLass.m(brasileiro.groovy:7)
> at CLass$m.call(Unknown Source)
> at brasileiro.run(brasileiro.groovy:13)
> {code}
> Exemple:
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic
> class CLass {
>     List m(){
>         String string = 'ABCD'
>         //ClassCastException here
>         return string.findAll(/(A)(B)(C)/) { String[] group->
>              return group[2]
>         }
>     }
> }
> new CLass().m(){code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to