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

SC: runtime error for default argument call expression

    XMLWordPrintableJSON

Details

    Description

      Follow up from GROOVY-6851 and GROOVY-9151. Consider the following:

      @groovy.transform.CompileStatic
      void greet(Object o = 'world', String s = o.toString()) {
          print "hello $s"
      }
      /*void greet() {
          Object o = 'world'
          greet(o, (String)o.toString()) // IncompatibleClassChangeError: Expected static method java.lang.Object.toString()Ljava/lang/String;
      }*/
      greet()
      

      The STCV only looks at the default argument expressions, not the generated methods. So there still can be issues in the statically compiled result.

      Attachments

        Activity

          People

            emilles Eric Milles
            emilles Eric Milles
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: