https://kotlinlang.org logo
Title
s

Sourabh Rawat

03/03/2022, 4:29 AM
Is this not fixed? https://youtrack.jetbrains.com/issue/KTIJ-18630 Can't access
reservation
parameter in debugger at the debug point at line 26. It says
This variable is inaccessible because it isn't used after the last suspension point
Using coroutines
1.6.0
e

ephemient

03/03/2022, 6:20 AM
it's fixed in that the IDE tells you why the variable isn't available
there's a separate issue for changing how coroutines are compiled to make such variables available, https://youtrack.jetbrains.com/issue/KT-48678
s

Sourabh Rawat

03/03/2022, 6:23 AM
Ah that is what I am exactly facing. Thanks a lot for sharing.
e

ephemient

03/03/2022, 6:23 AM
but FYI, even plain old (non-coroutine) Java code allows variables to be garbage-collected before the end of the scope if they aren't referenced by later statements: https://shipilev.net/jvm/anatomy-quarks/8-local-var-reachability/
of course that's a lot less likely to happen than the case where the coroutine state machine simply optimizes the variable out, but if coroutines were to keep them, they'd be stricter than plain old code