在将泛型类参数传递给方法时,Groovy上的StackOverflowError

时间:2014-03-06 14:08:15

标签: generics groovy intellij-idea

我正在使用Intellij IDEA 12并启用了Groovy插件。 我在这种情况下得到了关于make的StackOverflowError:

OItem.java:

public interface OItem<O extends Order<O, I, ?>, I extends OItem> extends DomainBase, Processable, ValidationListener{
    //Some methods
}

ROItem.java:

public interface ROItem extends OItem<ROrder, ROItem>, DomainBase {
    //Some methods
}

问题出在这里。当方法需要ROItem时,它会编译:

class MyScript {
    static void myMethod(ROItem orderItem) {
        //Empty inside
    }
}

但是当它需要OItem时,Groovyc会抛出SOError:

class MyScript {
    static void myMethod(OItem orderItem) {
        //Empty inside
    }
}

完整跟踪在这里:

Groovyc: java.lang.StackOverflowError
    at org.codehaus.groovy.ast.ClassNode.toString(ClassNode.java:1127)
    at org.codehaus.groovy.ast.ClassNode.genericTypeAsString(ClassNode.java:1160)
    at org.codehaus.groovy.ast.ClassNode.toString(ClassNode.java:1134)
    at org.codehaus.groovy.ast.ClassNode.genericTypeAsString(ClassNode.java:1160)
    at org.codehaus.groovy.ast.ClassNode.toString(ClassNode.java:1134)
    at org.codehaus.groovy.ast.ClassNode.toString(ClassNode.java:1120)
    at org.codehaus.groovy.ast.ClassNode.toString(ClassNode.java:1139)
    ...

这部分重复257次:

    at org.codehaus.groovy.ast.ClassNode.genericTypeAsString(ClassNode.java:1160)
    at org.codehaus.groovy.ast.ClassNode.toString(ClassNode.java:1134)
    at org.codehaus.groovy.ast.ClassNode.toString(ClassNode.java:1120)
    at org.codehaus.groovy.ast.ClassNode.toString(ClassNode.java:1139)

0 个答案:

没有答案