You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Aleks Tamarkin (Jira)" <ji...@apache.org> on 2020/08/10 21:25:00 UTC

[jira] [Updated] (GROOVY-9681) Groovy2 indy not backward compatible missingMethod with Groovy3

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

Aleks Tamarkin updated GROOVY-9681:
-----------------------------------
    Description: 
I am getting a
{code:java}
Exception in thread "main" java.lang.IllegalArgumentException: array is not of length 1{code}
To reproduce, compile the following in Groovy 2.5 with
{code:java}
groovyOptions.optimizationOptions.indy = true{code}
 
{code:java}
package first

import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
@CompileStatic class Library {   
    private x 
    Library(x) {
        this.x = x     
    } 
    @CompileDynamic     
    def foo(a, b= '<1>', c= '<2>') {
        "$a" + b + c     
    } 
    @CompileDynamic     
    def methodMissing(String name, args) {        
        foo([(name):x], *args[1..<args.size()])     
    } 
}{code}
Then reference the code in Groovy 3.0.5 to reproduce the error
{code:java}
package second 
import first.Library 
class App { 
    static void main(String[] args) { 
        println new Library(2).bar( 'a' )        
        println new Library(2).bin( 'a', 'b')     
    } 
}{code}
{color:#000000} {color}
 Note that if both are compiled with Groovy2 or Groovy3 the error does not occur.

This is probably similar to https://issues.apache.org/jira/browse/GROOVY-9515?jql=text%20~%20%22%5C%22array%20is%20not%20of%20length%201%5C%22%22

  was:
I am getting a
{code:java}
Exception in thread "main" java.lang.IllegalArgumentException: array is not of length 1{code}

To reproduce, compile the following in Groovy 2.5 with
{code:java}
groovyOptions.optimizationOptions.indy = true{code}
 
{code:java}
package first

import groovy.transform.CompileDynamic
import groovy.transform.CompileStatic
@CompileStatic class Library {   
    private x 
    Library(x) {
        this.x = x     
    } 
    @CompileDynamic     
    def foo(a, b= '<1>', c= '<2>') {
        "$a" + b + c     
    } 
    @CompileDynamic     
    def methodMissing(String name, args) {        
        foo([(name):x], *args[1..<args.size()])     
    } 
}{code}
Then reference the code in Groovy 3.0.5 to reproduce the error
 
{code:java}
package second 
import first.Library 
class App { 
    static void main(String[] args) { 
        println new Library(2).bar( 'a' )         println new Library(2).bin( 'a', 'b')     
    } 
}{code}
{color:#000000} {color}
Note that if both are compiled with Groovy2 or Groovy3 the error does not occur. 

This is probably similar to https://issues.apache.org/jira/browse/GROOVY-9515?jql=text%20~%20%22%5C%22array%20is%20not%20of%20length%201%5C%22%22


> Groovy2 indy not backward compatible missingMethod with Groovy3
> ---------------------------------------------------------------
>
>                 Key: GROOVY-9681
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9681
>             Project: Groovy
>          Issue Type: Bug
>          Components: Compiler
>            Reporter: Aleks Tamarkin
>            Priority: Major
>
> I am getting a
> {code:java}
> Exception in thread "main" java.lang.IllegalArgumentException: array is not of length 1{code}
> To reproduce, compile the following in Groovy 2.5 with
> {code:java}
> groovyOptions.optimizationOptions.indy = true{code}
>  
> {code:java}
> package first
> import groovy.transform.CompileDynamic
> import groovy.transform.CompileStatic
> @CompileStatic class Library {   
>     private x 
>     Library(x) {
>         this.x = x     
>     } 
>     @CompileDynamic     
>     def foo(a, b= '<1>', c= '<2>') {
>         "$a" + b + c     
>     } 
>     @CompileDynamic     
>     def methodMissing(String name, args) {        
>         foo([(name):x], *args[1..<args.size()])     
>     } 
> }{code}
> Then reference the code in Groovy 3.0.5 to reproduce the error
> {code:java}
> package second 
> import first.Library 
> class App { 
>     static void main(String[] args) { 
>         println new Library(2).bar( 'a' )        
>         println new Library(2).bin( 'a', 'b')     
>     } 
> }{code}
> {color:#000000} {color}
>  Note that if both are compiled with Groovy2 or Groovy3 the error does not occur.
> This is probably similar to https://issues.apache.org/jira/browse/GROOVY-9515?jql=text%20~%20%22%5C%22array%20is%20not%20of%20length%201%5C%22%22



--
This message was sent by Atlassian Jira
(v8.3.4#803005)