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

Error applying AST at runtime

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Incomplete
    • Affects Version/s: 2.4.0
    • Fix Version/s: None
    • Component/s: ast builder
    • Labels:
      None
    • Environment:
      Java 1.7.0_72-b14
      Gradle wrapper 2.2.1

      Description

      In groovy 2.4.0-rc-2 all was ok, but now I have an error in 2.4.0. I'm not sure if is an exception or maybe there was some bad code before. Exception raises, when in a gradle task, I convert a class that have an AST to javascript with grooscript. That conversion process compile the file. In tests I don't get the error, all is ok .The code fails here:

      private addDrawMethod(ClassNode classNode) {
              classNode.addMethod('draw', Modifier.PUBLIC, null, Parameter.EMPTY_ARRAY,
                      ClassNode.EMPTY_ARRAY, new AstBuilder().buildFromCode {
                  this.render()
                  gQuery.attachMethodsToDomEvents(this)
              }[0])
          }
      

      And the error is:

      General error during semantic analysis: AstBuilder.build(CompilePhase, boolean, Closure):List<ASTNode> should never be called at runtime.
        Are you sure you are using it correctly?
      
      java.lang.IllegalStateException: AstBuilder.build(CompilePhase, boolean, Closure):List<ASTNode> should never be called at runtime.
        Are you sure you are using it correctly?
      
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        	at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
        	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        	at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
        	at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:77)
        	at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:102)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:190)
        	at org.codehaus.groovy.ast.builder.AstBuilder.buildFromCode(AstBuilder.groovy:78)
        	at org.codehaus.groovy.ast.builder.AstBuilder.buildFromCode(AstBuilder.groovy)
        	at org.codehaus.groovy.ast.builder.AstBuilder$buildFromCode.call(Unknown Source)
        	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:45)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
        	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
        	at react.ComponentImpl.addDrawMethod(ComponentImpl.groovy:71)
      

      If you want to reproduce the error can clone the repository (https://github.com/chiquitinxx/grooscript-demos.git) and run task (./gradlew convertReact)

        Attachments

          Activity

            People

            • Assignee:
              guillaume Guillaume Sauthier
              Reporter:
              chiquitinxx Jorge Franco Leza
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: