You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2020/01/27 00:45:01 UTC

[jira] [Closed] (GROOVY-9341) SC: Lambda within lambda that references "this" produces cast exceptions

     [ https://issues.apache.org/jira/browse/GROOVY-9341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Paul King closed GROOVY-9341.
-----------------------------

> SC: Lambda within lambda that references "this" produces cast exceptions
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-9341
>                 URL: https://issues.apache.org/jira/browse/GROOVY-9341
>             Project: Groovy
>          Issue Type: Bug
>    Affects Versions: 3.0.0-rc-2
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Major
>             Fix For: 3.0.0-rc-3
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Follow up to GROOVY-9332 and GROOVY-9333.  Consider the following:
> {code:groovy}
> @groovy.transform.CompileStatic
> class ThisTest {
>   private final ThisTest that = this
>   void m() {
>     java.util.function.Predicate<ThisTest> p1 = (ThisTest t1) -> {
>       java.util.function.Predicate<ThisTest> p2 = (ThisTest t2) -> {
>         assert this === t1 && this === t2
>       }
>       p2.test(t1)
>     }
>     p1.test(that)
>     p1.test(this)
>   }
> }
> new ThisTest().m()
> {code}
> {code}
> java.lang.ClassCastException: ThisTest$_m_lambda1 cannot be cast to ThisTest
>         at ThisTest$_m_lambda1$_lambda2.doCall(TestScript4.groovy:9)
>         at ThisTest$_m_lambda1.doCall(TestScript4.groovy:11)
>         at ThisTest.m(TestScript4.groovy:13)
>         at ThisTest$m.call(Unknown Source)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)