You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2019/04/17 11:39:00 UTC

[jira] [Updated] (GROOVY-8907) StringGroovyMethods.findAll(String, Pattern, Closure) and StringGroovyMethods.findAll(CharSequence, Pattern, Closure) is with @ClosureParams incorrect

     [ https://issues.apache.org/jira/browse/GROOVY-8907?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King updated GROOVY-8907:
------------------------------
    Fix Version/s: 2.5.7
                   3.0.0-beta-1

> 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.0.0-alpha-4, 2.5.6
>            Reporter: Henrique Mota
>            Priority: Minor
>             Fix For: 3.0.0-beta-1, 2.5.7
>
>         Attachments: image.png
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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)