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

StackOverflow with CompileStatic

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.0-rc-1
    • Fix Version/s: 2.1.0-rc-2, 2.0.7
    • Component/s: None
    • Labels:
      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

            • Assignee:
              melix C├ędric Champeau
              Reporter:
              tim_yates Tim Yates
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: