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

StackOverflow with CompileStatic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.1.0-rc-1
    • 2.1.0-rc-2, 2.0.7
    • None
    • None

    Description

      If I do this:

      @groovy.transform.CompileStatic
      class Element {
        String name
      
        static Iterator<Element> single() {
          [ new Element( name: 'single' ) ].iterator()
        }
      
        static Iterator<List<Element>> multi() {
          [ [ new Element( name: 'first' ), new Element( name: 'second' ) ] ].iterator()
        }
      
        static caller( boolean useSingle ) {
          useSingle ? single() : multi()
        }
      }
      
      println Element.caller( false ).collect()
      println Element.caller( true ).collect()
      

      I get:

      java.lang.StackOverflowError
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolveType(StaticTypeCheckingVisitor.java:2936)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolve(StaticTypeCheckingVisitor.java:2912)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolveType(StaticTypeCheckingVisitor.java:2936)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolve(StaticTypeCheckingVisitor.java:2912)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolveType(StaticTypeCheckingVisitor.java:2936)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolve(StaticTypeCheckingVisitor.java:2912)
      	at org.codehaus.groovy.transform.stc.StaticTypeCheckingVisitor.fullyResolveType(StaticTypeCheckingVisitor.java:2936)
        ...
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            tim_yates Tim Yates
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: