[ 
https://issues.apache.org/jira/browse/GROOVY-9565?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17720959#comment-17720959
 ] 

Eric Milles edited comment on GROOVY-9565 at 5/9/23 8:41 PM:
-------------------------------------------------------------

{{StackOverflowError}} resolved in Groovy 2.5.14+.

To get your example project to run test successfully, I needed to make a small 
change:
{code:groovy}
class Library {
    @groovy.transform.TypeChecked
    GenericConsumer findOrCreateTheProblematicClass(String aCategory) {
        GenericConsumer problemClass = anotherTestMethod { ->
            Class<? extends GenericConsumer> gc = 
GenericConsumer.findSpecificType(aCategory)
            gc.testMethod()
        }
        return problemClass
    }
{code}


was (Author: emilles):
{{StackOverflowError}} resolved in Groovy 2.5.14+.

To get your example project to run test successfully, I needed to make a small 
change:
{code:groovy}
class Library {
        @groovy.transform.CompileDynamic
    GenericConsumer findOrCreateTheProblematicClass(String aCategory) {
        GenericConsumer problemClass = anotherTestMethod { ->
            Class<? extends GenericConsumer> gc = 
GenericConsumer.findSpecificType(aCategory)
            gc.testMethod()
        }
        return problemClass
    }
{code}

> StackoverflowError when using an abstract class with generic parameters as 
> the return value of a closure
> --------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-9565
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9565
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static Type Checker
>    Affects Versions: 2.5.11, 2.5.12, 2.5.13
>            Reporter: Daniel Demus
>            Assignee: Eric Milles
>            Priority: Major
>              Labels: StackOverflowError
>             Fix For: 2.5.14
>
>
> If you try to compile the project at 
> [https://github.com/demus-nine/groovy-class-generic-stackoverflowerror] 
> groovyc crashes with a StackoverflowError. This happens in 
> org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport#applyGenericsContext(java.util.Map<org.codehaus.groovy.ast.GenericsType.GenericsTypeName,org.codehaus.groovy.ast.GenericsType>,
>  org.codehaus.groovy.ast.ClassNode) in this bit of recursive code:
> {code:java}
> if (bound.isArray()) {
>     return applyGenericsContext(spec, bound.getComponentType()).makeArray();
> }
> {code}
> although I have seen it throw in other methods in the 
> StaticTypeCheckingSupport class.
>  
> The class that is being handled is an abstract class with a generic 
> parameter, but in the code using the type there aren't enough hints to the 
> compiler to resolve the generic constraint, possibly because it is 
> self-referential.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to