[ https://issues.apache.org/jira/browse/GROOVY-6668?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16478502#comment-16478502 ]
ASF GitHub Bot commented on GROOVY-6668: ---------------------------------------- Github user danielsun1106 commented on a diff in the pull request: https://github.com/apache/groovy/pull/708#discussion_r188837462 --- Diff: src/test/groovy/bugs/Groovy6668Bug.groovy --- @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package groovy.bugs + +class Groovy6668Bug extends GroovyTestCase{ + void testGroovy6668() { + assertScript ''' + @groovy.transform.CompileStatic + class OtherThing { + OtherThing() { + Map<String, String> m = [:] + def k = "foo" + m["$k"].toUpperCase() + } + } + + OtherThing --- End diff -- I've fixed that according your suggestion :-) > Static compiler doesn't coerce GString for getAt() call > ------------------------------------------------------- > > Key: GROOVY-6668 > URL: https://issues.apache.org/jira/browse/GROOVY-6668 > Project: Groovy > Issue Type: Bug > Components: Static compilation > Affects Versions: 2.3.0-beta-1, 2.4.0-rc-1 > Reporter: Luke Daley > Priority: Major > > This might not be a bug, but it's a behaviour change from 2.2. > {code} > @groovy.transform.CompileStatic > class OtherThing { > OtherThing() { > Map<String, String> m = [:] > def k = "foo" > m["$k"].toUpperCase() // fails, no method toUpperCase() on object > m[k].toUpperCase() // works > } > } > {code} -- This message was sent by Atlassian JIRA (v7.6.3#76005)