Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
2.0.4
-
None
Description
When using @CompileStatic or @TypeChecked the StaticTypeCheckingVisitor recursively calls itself on the following example:
abstract class Base<A extends Base<A>> {} class Done extends Base<Done> { } class Next<H, T extends Base<T>> extends Base<Next<H, T>> { H head; T tail static Next<H, T> next(H h, T t) { new Next<H, T>(head:h, tail:t) } String toString() { "Next($head, ${tail.toString()})" } } import static Next.* @groovy.transform.CompileStatic def foo() { Next<Integer, Next<String, Done>> x = next(3, next("foo", new Done())) } println foo() // => Next(3, Next(foo, Done@9b3ec2))
My real example is when using Functional Java's heterogeneous list classes but the above is a cut-down equivalent. The stack trace is:
java.lang.StackOverflowError ... org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolve(StaticTypeCheckingVisitor.java:2836) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolveType(StaticTypeCheckingVisitor.java:2873) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolve(StaticTypeCheckingVisitor.java:2840) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolveType(StaticTypeCheckingVisitor.java:2873) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolve(StaticTypeCheckingVisitor.java:2840) at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolveType(StaticTypeCheckingVisitor.java:2873)