什么是@InlineOnly批注? [英] What is the @InlineOnly annotation?

查看:77
本文介绍了什么是@InlineOnly批注?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请参见 the @InlineOnly 注释stdlib.据我所知,注释仅碰巧在inline函数上.此注释的目的是什么?总是内联inline函数不是很明显吗?它的文档并没有真正的帮助

I often see the @InlineOnly annotation when browsing Kotlin's stdlib. As far as I recall the annotation only happens to be on inline functions. What is the purpose of this annotation? Isn't it obvious that inline functions are always inlined? It's documentation isn't really helpful

指定不应在没有内联的情况下直接调用此函数

Specifies that this function should not be called directly without inlining

是否可以将内联函数称为非内联函数?

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

推荐答案

引用找到的答案此处:

InlineOnly表示与此Kotlin对应的Java方法 该功能被标记为私有,因此Java代码无法访问该功能( 是不实际内联而调用内联函数的唯一方法 它).

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 is internal only because

此注释是在发布前的最后一刻添加的,因此我们没有时间验证设计,因此决定将其保留一段时间.我们很有可能稍后再公开.

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.

这篇关于什么是@InlineOnly批注?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆