[
https://issues.apache.org/jira/browse/GROOVY-11011?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-11011:
---------------------------------
Description:
Consider the following:
{code:groovy}
@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)
}
}
}
}
{code}
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.
was:
Consider the following:
{code:groovy}
@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, (byte[]) arg)
} else if (arg instanceof File) {
file(name, (File) arg)
}
}
}
}
{code}
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.
> SC: array instanceof guard and length or subscript
> --------------------------------------------------
>
> Key: GROOVY-11011
> URL: https://issues.apache.org/jira/browse/GROOVY-11011
> Project: Groovy
> Issue Type: Bug
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Major
>
> Consider the following:
> {code:groovy}
> @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)
> }
> }
> }
> }
> {code}
> 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.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)