Details
-
Bug
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.0.0-alpha-4, 2.5.6
-
None
Description
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
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)
Exemple:
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()