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

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

daniellansun opened a new pull request, #3342:
URL: https://github.com/apache/groovy/pull/3342

   https://issues.apache.org/jira/browse/GROOVY-2994
   
   `"${1}" + "2"` and `"${1}".plus("2")` now return a String, as `"1" + "${2}"` 
already did. `GString.plus(String)` renders the receiver and appends the 
argument, so the two orders agree on the result type. The text is unchanged.
   
   This is a Groovy 7 behavioral change and should not be backported to 6.0.x. 
Before, a GString on the left produced another GString, so values stayed 
unrendered until `toString`, `writeTo` or `build`, and `groovy.sql.Sql` could 
still bind parameters from a query built by appending a plain String. A class 
compiled against the previous `plus(String)` descriptor will throw 
`NoSuchMethodError` until it is recompiled. Code that needs the result to 
remain a GString should keep both sides as GString (`GString.plus(GString)` is 
unchanged).
   
   `testGroovy2994` now runs as a regular test; its assertions are unchanged. 
Additional coverage is in `Groovy2994`.
   




> String and GString do not commute under plus()
> ----------------------------------------------
>
>                 Key: GROOVY-2994
>                 URL: https://issues.apache.org/jira/browse/GROOVY-2994
>             Project: Groovy
>          Issue Type: Bug
>          Components: groovy-runtime
>    Affects Versions: 1.5.6
>            Reporter: Alexander Veit
>            Assignee: Daniel Sun
>            Priority: Major
>
> assert "${1}" + "2" instanceof GString
> assert "1" + "${2}" instanceof String
> As far as I can see plus() should be commutative throughout the GDK. At least 
> it should be commutative for String and GString.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to