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
agrosner
04/12/2022, 1:51 PM
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
sindrenm
04/12/2022, 1:54 PM
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
agrosner
04/12/2022, 2:03 PM
since its inlined into source, i take it
private
means that none of its body of code gets into visible sources
agrosner
04/12/2022, 2:03 PM
so probably an unwravel
s
sindrenm
04/12/2022, 3:17 PM
I guess thinking about it like that makes more sense. 👍
r
rocketraman
04/14/2022, 4:43 AM
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
sindrenm
04/14/2022, 8:17 AM
Oh, that looks like it's made for this purpose exactly! Thanks!