Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-9515

MethodHandle with spread args should not be cached

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-alpha-1, 3.0.4
    • Compiler
    • None

    Description

      import org.codehaus.groovy.control.CompilerConfiguration
      
      def config = new CompilerConfiguration()
      config.optimizationOptions.indy = true
      new GroovyShell(config).evaluate '''
      def x(int a) {a}
      def x(int a, int b) {a + b}
      def y(p) {
          x(*p)
      }
      assert 1 == y([1])
      assert 3 == y([1, 2])
      '''
      

      Error message:

      java.lang.IllegalArgumentException: array is not of length 1
      
      	at Script1.y(Script1.groovy:5)
      
      	at Script1.run(Script1.groovy:8)
      
      	at ConsoleScript1.run(ConsoleScript1:5)
      
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      
      	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      
      	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      
      

      Attachments

        Issue Links

          Activity

            People

              daniel_sun Daniel Sun
              daniel_sun Daniel Sun
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 20m
                  20m