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 2018/11/20 23:25:00 UTC
[jira] [Comment Edited] (GROOVY-8882) STC: Loop over elements of
String has different element type
[ https://issues.apache.org/jira/browse/GROOVY-8882?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16693890#comment-16693890 ]
Paul King edited comment on GROOVY-8882 at 11/20/18 11:24 PM:
--------------------------------------------------------------
Even this exhibits the {{Character}} coercion behavior with STC:
{code}
for (String c in 'abc')
{code}
This does {{Character}} coercion with and without STC as I'd expect:
{code}
for (Character c in 'abc')
{code}
was (Author: paulk):
Even this exhibits the {{Character}} coercion behavior:
{code}
for (String c in 'abc')
{code}
> STC: Loop over elements of String has different element type
> ------------------------------------------------------------
>
> Key: GROOVY-8882
> URL: https://issues.apache.org/jira/browse/GROOVY-8882
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 2.4.15
> Reporter: Eric Milles
> Priority: Minor
>
> When the method below is executed as-is, the output is "java.lang.String" x3. When {{@CompileStatic}} is uncommented, the output is "java.lang.Character" x3. Is it possible to have dynamic groovy match the static compilation result?
> {code:groovy}
> //@groovy.transform.CompileStatic
> void meth() {
> for (c in 'abc')
> println c.class.name
> }
> {code}
> Similarly, {{'abc'*.anything}} applies to Strings of length one instead of Characters. Although, spread-dot is not supported against strings under static compilation. Is it possible to add that support?
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)