stellarspot
07/30/2019, 1:17 PMinline
is used as
The inline modifier affects both the function itself and the lambdas passed to it: all of those will be inlined into the call site.
In case you want only some of the lambdas passed to an inline function to be inline, you can mark some of your function parameters with the noinline modifier:
What If I do not need to make the whole function inline but want that its passed lambdas are made inline?
For example my function have private fields and to make it inline it is necessary to annotate the whole function with @Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
.
If a function with lambda arguments is not marked as inline
will the compiler smart enough to inline the lambda in the function body if the only lambda usage is its invocation?
https://kotlinlang.org/docs/reference/inline-functions.htmldiesieben07
07/30/2019, 1:21 PMstellarspot
07/30/2019, 1:33 PMilya.gorbunov
07/30/2019, 2:36 PM@Suppress("NON_PUBLIC_CALL_FROM_PUBLIC_INLINE")
. Use @PublishedApi
+ internal
visibility for those non-public declarations that you want to call from the inline function.stellarspot
07/30/2019, 3:55 PMdiesieben07
07/31/2019, 7:51 AM