https://kotlinlang.org logo
#announcements
Title
# announcements
a

Aaron Stacy

06/16/2020, 4:22 PM
Hi all, I'm trying to figure out why I can't reference an outer class's
this
for a lambda with a receiver. Here's a code snippet https://pl.kotl.in/GtgL1DMFc . Based on https://kotlinlang.org/docs/reference/this-expressions.html it seems like I should be able to reference the outer
this
via a label, so why can't the compiler resolve the
@A
reference? Thanks!
d

diesieben07

06/16/2020, 4:25 PM
You are trying to reference the
this
of
value
, not the
this
of
A
(your function doesn't have an outer
A
). So
this@value
is what you want.
👏 1
a

Aaron Stacy

06/16/2020, 4:33 PM
Thank you so much!
Ah, but
this@value::doSomething
fails because its receiver is not
CoroutineScope
. Oh well.
r

Ruckus

06/16/2020, 5:19 PM
Yeah, there isn't support for multiple receivers is Kotlin. Hopefully someday, as it would make some DSLs extra slick.
2 Views