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/15 18:40:00 UTC
[jira] [Created] (GROOVY-9341) SC: Lambda within lambda that
references "this" produces cast exceptions
Eric Milles created GROOVY-9341:
-----------------------------------
Summary: 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
Reporter: Eric Milles
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)