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

Ian

06/30/2017, 4:21 PM
Got a weird puzzler with receivers. I have a codeblock to which a receiver has been passed. The outer codeblock also has a receiver of the same type. For some reason, when I attempt to call a method on the receiver, it’s calling the outer codeblock’s receiver instead of the inner codeblock’s receiver. I’ve checked in the debugger and $receiver is the correct inner receiver within the inner codeblock, and yet when the method is called the $receiver within it becomes the outer codeblock’s receiver. Hope this makes sense, anyone have any ideas? edit Cleaned up code example and posted to reddit, replies welcome there or here: https://www.reddit.com/r/Kotlin/comments/6kh10d/dsl_receiver_puzzler/
i

ilya.gorbunov

07/01/2017, 1:06 AM
ianclarke: How is your
ul
defined? I wasn't able to reproduce it, see this snippet: https://try.kotlinlang.org/#/UserProjects/6lghlke9al5s0dm1bk1l080da8/m9g58nct4gn1a48vn261oh01l0
i

Ian

07/01/2017, 4:27 PM
Hey, sorry for the slow reply. I figured it out once I used the DSL annotation - turned out that the parameterized type was different for the child receiver so it used the parent receiver instead.