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/
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.