[ 
https://issues.apache.org/jira/browse/GROOVY-12577?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18135253#comment-18135253
 ] 

ASF GitHub Bot commented on GROOVY-12577:
-----------------------------------------

codeconsole commented on PR #3103:
URL: https://github.com/apache/groovy/pull/3103#issuecomment-6526607071

   @daniellansun
   1. Merged master, which has the LSP fix (#3094), so CI runs again.
   2. The partial is the `!controller.isInGeneratedFunction()` half of the new 
condition: a closure or lambda in a static method or initializer reaches that 
line with a generated function and takes the existing `thisObjectExpression` 
branch, which already worked. `testCallClassMethodFromClosureInStaticContext` 
(bdea8ad3eb) now covers that path (closure in a static field initializer, 
nested closures and a lambda in static methods); it passes before and after the 
change, so it pins the existing behaviour rather than the fix. 
`testCallClassMethodFromStaticContext` still fails without the change with the 
`VerifyError`.




> SC: a method of Class called without a receiver in a static method fails 
> verification
> -------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12577
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12577
>             Project: Groovy
>          Issue Type: Bug
>          Components: Static compilation
>    Affects Versions: 5.0.8, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> @groovy.transform.CompileStatic
> class C {
>     static String m() { getSimpleName() }
> }
> C.m() // VerifyError: Bad local variable type ... C.m()Ljava/lang/String; @0: 
> aload_0
> {code}
> In a static method or static initializer, {{this}} is the class object, and 
> the type checker accepts a call to a method of {{Class}} without a receiver, 
> like {{getName()}}, {{getSimpleName()}} or {{toString()}}. The static 
> invocation writer treats the method as one of an enclosing class and loads 
> {{Class.this}}, local variable 0, which does not exist in a static method. 
> Methods of {{Object}}, such as {{hashCode()}}, work. 4.0.33 returns {{'C'}}, 
> as dynamic Groovy and an explicit {{this.getSimpleName()}} do.
> PR: https://github.com/apache/groovy/pull/3103



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to