Today I learned that a public inline function can'...
# random
s
Today I learned that a public inline function can't call a private inline function, and it's driving me mad.
Copy code
inline fun foo() = bar() // does not compile
private inline fun bar() {}
a
makes sense to me, just surely annoying. what ive done is make a public / visible wrapper if I needed to. either between the foo / bar level, or foo + outside
s
Technically, I guess the private stuff could be inlined into the public stuff before the public stuff got inlined to wherever it's called, but I'm not well versed in the order of which the compiler inlines its stuff.
a
since its inlined into source, i take it
private
means that none of its body of code gets into visible sources
so probably an unwravel
s
I guess thinking about it like that makes more sense. 👍
r
You can make it "effectively public" like this:
Copy code
inline fun foo() = bar() // compiles!
  
  @PublishedApi
  internal inline fun bar() {}
Read the docs for
@PublishedApi
.
👍 1
s
Oh, that looks like it's made for this purpose exactly! Thanks!