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

SC: array instanceof guard and length or subscript

    XMLWordPrintableJSON

Details

    Description

      Consider the following:

      @groovy.transform.CompileStatic
      class FileTreeBuilder {
          def methodMissing(String name, Object args) {
              if (args instanceof Object[] && args.length == 1) {
                  def arg = args[0]
                  if (arg instanceof Closure) {
                      dir(name, arg)
                  } else if (arg instanceof CharSequence) {
                      file(name, arg.toString())
                  } else if (arg instanceof byte[]) {
                      file(name, arg)
                  } else if (arg instanceof File) {
                      file(name, arg)
                  }
              }
          }
      }
      

      STC gives no errors for this, but there are 2 class format issues. "args.length" is reporting bad type on operand stack and "if (arg instanceof CharSequence)" and subsequent guards are reporting improper class name "Ljava/lang/Object;" on the operand stack.

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: