[
https://issues.apache.org/jira/browse/GROOVY-9341?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Daniel Sun resolved GROOVY-9341.
--------------------------------
Fix Version/s: 3.0.0-rc-3
Resolution: Fixed
> 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)