https://kotlinlang.org logo
Title
p

pp.amorim

09/20/2018, 3:41 PM
Is there any way to use private functions on inlined functions? I know it does not make sense for the compiler, could be implemented any special visibility modifier for inline functions?
d

diesieben07

09/20/2018, 3:42 PM
You can use
internal
in combination with
@PublishedApi
.
p

pp.amorim

09/20/2018, 3:43 PM
Jimmy can call
nukeWorld()
anytime 😰
d

diesieben07

09/20/2018, 3:43 PM
Sorry... what?
p

pp.amorim

09/20/2018, 3:43 PM
it's a joke
d

diesieben07

09/20/2018, 3:43 PM
Yes, I get that. But I don't get the context 😄
s

Shawn

09/20/2018, 3:44 PM
lol if I had to guess they mean that someone might be able to access methods that really ought to be private just so as long as they’re calling it from Kotlin
but I mean ultimately this confers a breach in encapsulation, whether you do it via annotation or if the compiler allows you to call private methods in an inlined function
d

diesieben07

09/20/2018, 3:46 PM
It would not even work once compiled, since the function is still private, so it cannot actually be called from the callsite where the function is inlined to.
p

pp.amorim

09/20/2018, 3:47 PM
it's ok to make the check on compile time
d

diesieben07

09/20/2018, 3:48 PM
Question is: Why does the function have to be inline?
p

pp.amorim

09/20/2018, 3:48 PM
because it has lambdas and are called very often
d

diesieben07

09/20/2018, 3:48 PM
Okay. Then
internal
+
@PublishedApi
is the best you can do.
p

pp.amorim

09/20/2018, 3:49 PM
thanks 😄