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

CompileStatic - Calling vargarg parameter String is converted to array of strings

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.0.4
    • Component/s: None
    • Environment:
      Windows 7 64bits, JDK 1.7.0_04

      Description

      Assume we have this method:

      static void printMsgs(String ... msgs) {
          for(String s : msgs) { println s;}
      }
      

      Calling it from @CompileStatic:

      @CompileStatic
        static void testCS() {
          //Print:
          // H
          // e
          // l
          // l
          // o
          printMsgs("Hello");
        }
      

      The string 'hello' is converted to array of strings.

      Calling it from non CompileStatic works fines.

      The complete test case:

      public class CompileStaticVarArg {
      
        static void main(String[] args) {
      
      
          test();
      
          println '-' * 20
      
          testCS()
      
        }
      
      
        static void test() {
          // Print 'hello'
          printMsgs("Hello");
        }
      
        @CompileStatic
        static void testCS() {
          //Print:
          // H
          // e
          // l
          // l
          // o
          printMsgs("Hello");
        }
      
        static void printMsgs(String ... msgs) {
      
          for(String s : msgs) {
            println s;
          }
      
        }
      
      }
      

        Attachments

          Activity

            People

            • Assignee:
              melix Cédric Champeau
              Reporter:
              boaznahum Boaz Nahum
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: