You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2019/12/11 17:29:00 UTC
[jira] [Resolved] (GROOVY-9333) `this` within native lambda does
not reference the instance of enclosing class
[ https://issues.apache.org/jira/browse/GROOVY-9333?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Eric Milles resolved GROOVY-9333.
---------------------------------
Resolution: Fixed
> `this` within native lambda does not reference the instance of enclosing class
> ------------------------------------------------------------------------------
>
> Key: GROOVY-9333
> URL: https://issues.apache.org/jira/browse/GROOVY-9333
> Project: Groovy
> Issue Type: Bug
> Affects Versions: 3.0.0-rc-2
> Reporter: Daniel Sun
> Assignee: Eric Milles
> Priority: Major
> Fix For: 3.0.0-rc-3
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> {code:java}
> import groovy.transform.CompileStatic
> @CompileStatic
> public class Test4 {
> public static void main(String[] args) {
> new Test4().p();
> }
>
> public String hello = "Hello ";
> public void p() {
> assert ['Hello Jochen', 'Hello Daniel'] == ["Jochen", "Daniel"].stream().map(e -> this.hello + e).toList();
> }
> }
> {code}
> Error message:
> {code:java}
> java.lang.ClassCastException: class Test4$_p_lambda1 cannot be cast to class Test4 (Test4$_p_lambda1 and Test4 are in unnamed module of loader groovy.lang.GroovyClassLoader$InnerLoader @1e05551b)
> at Test4$_p_lambda1.doCall(ConsoleScript2:12)
> at Test4.p(ConsoleScript2:12)
> at Test4.main(ConsoleScript2:6)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)