Leon K
02/19/2020, 12:48 PMsuspend
, make the function suspend
, otherwise don't". I know the same thing can be achieved using inline fun
, but I have to access private fields in this function so that's not an optiondiesieben07
02/19/2020, 12:51 PMsuspend
(it has to take an additional Continuation
parameter)diesieben07
02/19/2020, 12:52 PMinline
and encapsulate the private access in a @PublishedApi internal fun
which does not suspend and doesn't use the lambda.Leon K
02/19/2020, 1:07 PMdiesieben07
02/19/2020, 1:10 PMLeon K
02/19/2020, 1:13 PMdiesieben07
02/19/2020, 1:17 PMLeon K
02/19/2020, 1:18 PMdiesieben07
02/19/2020, 1:21 PMprivate
(or in a private
class) then it can only ever be inline in the same class / file, so wherever it is inlined to also has access to the same private fields.diesieben07
02/19/2020, 1:22 PMprivate
fields are not part of your public API. If you could access them inside an inline
function they suddenly would be, because the code of your inline function gets copied into other people's code.Leon K
02/19/2020, 1:26 PM