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

Compile static failing to allow cast of groovy type to GroovyObject

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.0
    • 2.0.1
    • Static compilation
    • None

    Description

      I tried to see if this was already fixed or covered by another issue, but I couldn't find something like it... Here is the code:

      class Foo {
          @groovy.transform.CompileStatic
          public void blah() {
              ((GroovyObject)this);
          }
      }
      

      This is currently causing me an issue when trying to build grails-core in STS (it has a snippet somewhat similar to this, but obviously it does a bit more). For some reason it works through the gradle build on the command line, but not if I just run groovy 2.0.0 groovyc against that class above. I also grabbed a snapshot and tried it, which seemed to give the same result.

      Oh, the error is:

      > groovyc Foo.groovy
      org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
      Foo.groovy: 4: [Static type checking] - Inconvertible types: cannot cast Foo to groovy.lang.GroovyObject
       @ line 4, column 3.
         		((GroovyObject)this);
           ^
      
      1 error
      

      Attachments

        Activity

          People

            melix Cédric Champeau
            aclement Andy Clement
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: