当浏览Kotlin的stdlib时,I often see the @InlineOnly注释.据我回忆,注释恰好只在inline个函数上.这个注释的目的是什么?inline个函数总是内联的,这不是很明显吗?它的文档并没有真正的帮助

Specifies that this function should not be called directly without inlining

Is it possible for inline functions to be called not inline?

推荐答案

引用here的答案:

InlineOnly means that the Java method corresponding to this Kotlin function is marked private so that Java code can not access it (which is the only way to call an inline function without actually inlining it).

此注释为internal只是因为

This annotation was added in the last moment before release, so we hadn't time to validate the design and decided to keep it internal for a while. There are good chances we make it public later.

Kotlin相关问答推荐

Kotlin-删除按钮周围的空格

解决Microronaut中多个可能的Bean候选者冲突

如何在Spring Boot中注册新的集合工厂

kotlin中如何使用子类调用父静态方法?

Spring Boot Kotlin 数据类未使用 REST 控制器中的默认值初始化

为什么 Kotlin 在将协变类型参数转换为不变类型参数时会产生 Unchecked Cast 警告?

Android Jetpack Compose:在空的 Compose 活动中找不到 OutlinedTextField (Material3)

有没有一种简单的方法可以将数组/列表中的每个元素相互相乘 - Kotlin?

Kotlin 插件之间的区别

我们应该在 Effect 和 Either 之间 Select 哪个作为我们业务服务的返回类型?

SpringBoot 2.5.0 对于 Jackson Kotlin 类的支持,请在类路径中添加com.fasterxml.jackson.module: jackson-module-kotlin

JobIntentService 被销毁,当应用程序被销毁时

为什么 IntelliJ Idea 无法识别我的 Spek 测试?

如何使用 Findbugs 避免 kotlin 文件

在粘贴时将 java 转换为 kotlin

找不到 androidsdk.modules

Kotlin:使用Gradle进行增量编译

Java Integer.MAX_VALUE 与 Kotlin Int.MAX_VALUE

使用 kotlin 每 3 位数添加逗号或点

尾随 lambda 语法(Kotlin)的目的是什么?