What is @InlineOnly annotation?

I often see @InlineOnly annotation when viewing Kotlin stdlib. As far as I remember, annotation is only mentioned in inline functions. What is the purpose of this annotation? Isn't it obvious that inline functions are always inlined? The documentation is not very helpful.

Indicates that this function cannot be called directly without insertion.

Is it possible for inline functions to be called out of line?

+4
kotlin
source share
1 answer

To quote the answer here :

InlineOnly means that the Java method corresponding to this Kotlin function is marked as confidential, so Java code cannot access it (this is the only way to call an inline function without actually embedding it).

This annotation is internal only because

This annotation was added at the last moment before the release, so we did not have time to check the design and decided to keep it for a while. There are good features that we publish later.

+5
source share

All Articles