codeconsole opened a new pull request, #3103:
URL: https://github.com/apache/groovy/pull/3103

   Under `@CompileStatic`, a static method or static initializer that calls 
`getName()`, `getSimpleName()` or `toString()` without a receiver now calls it 
on the class object, as dynamic Groovy, an explicit `this.getSimpleName()` and 
4.0 do. Before, the class failed verification:
   
   ```groovy
   @CompileStatic
   class C {
       static String m() { getSimpleName() }   // VerifyError: Bad local 
variable type ... aload_0
   }
   ```
   
   The static invocation writer treated the method as one of an enclosing class 
and loaded `Class.this`, local variable 0, which does not exist in a static 
method. Methods of `Object`, such as `hashCode()`, already worked.
   
   Tests: `MethodCallsSTCTest.testCallClassMethodFromStaticContext` (also run 
statically compiled by `MethodCallsStaticCompilationTest`), which fails without 
the change. The `groovy`, `gls`, `bugs` and `org.codehaus.groovy` packages pass 
(15,497 tests), apart from `bugs.Groovy12363`, which also fails on master when 
it runs after `bugs.Groovy12142` in the same JVM (GROOVY-12580 fixes it). The 
Checkstyle and CodeNarc gates pass.
   
   A regression in 5.0.0: 4.0.33 is correct, 5.0.8 and 6.0.0 are not.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to