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

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

testlens-app[bot] commented on PR #3175:
URL: https://github.com/apache/groovy/pull/3175#issuecomment-6611118122

   ## ✅ All tests passed ✅
   
   🏷️ Commit: cd74e4e61ad7013611aea23339e1479126294b78
   ▶️ Tests:  127467 executed
   ⚪️ Checks: 26/26 completed
   
   ---
   _Learn more about TestLens at 
[testlens.app/docs](https://testlens.app/docs/features/pr-comment/)._
   




> SC: calling an instance method of Class without a receiver in a static method 
> fails verification or uses the wrong receiver
> ---------------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12654
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12654
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 5.0.8, 7.0.0-alpha-1, 6.0.0
>            Reporter: Scott Murphy Heiberg
>            Priority: Major
>
> {code:groovy}
> @groovy.transform.CompileStatic
> class C {
>     static Object sm() { getName() }
>     static Object st() { toString() }
>     static Object sp(Class type) { getName() }
> }
> println C.sm(); println C.st(); println C.sp(String)
> {code}
> *Actual:* {{java.lang.VerifyError: Bad local variable type}} 
> ({{C.sm()Ljava/lang/Object; @0: aload_0}}). With only {{sp}}, it prints 
> {{java.lang.String}}: the method is called on the parameter. A static field 
> initializer such as {{static String p = getName()}} fails the same way in the 
> static initializer. With closure packing ({{groovy.target.closure.pack=true}} 
> or {{@PackedClosures}}), a closure in a static method is hoisted into a 
> static method, so {{static m() ... toString() inside a closure}} fails 
> verification the same way.
> *Expected:* {{C}}, {{class C}}, {{C}}, as in dynamic and {{@TypeChecked}} 
> code, and as in 4.0.33.
> Cause: for an implicit-this call to a method declared outside the enclosing 
> class, {{StaticInvocationWriter.writeDirectMethodCall}} builds the receiver 
> {{Type.this}}, which in a static method loads local slot 0 instead of the 
> class.
> Verified: 4.0.33 prints the expected values; 5.0.8, 6.0.0 and master fail.



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

Reply via email to