本文介绍了错误:带有@OptionalExpectation注释的声明只能在通用模块源中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
更新(2018-11-03)
这是一个已知的问题,正在此处.
This is a known issue that is being tracked here.
原始帖子
我正在使用Kotlin MPP,尤其是Kotlin 1.3和新结构.将Kotlin 1.2 MPP转换为新结构后,我不断出现以下错误:
I am playing around with Kotlin MPP, specifically with Kotlin 1.3 and the new structure. After converting a Kotlin 1.2 MPP to the new structure, I keep getting these errors:
Error:(3, 18) Kotlin: [MPP_jvmMain] Declaration annotated with '@OptionalExpectation' can only be used in common module sources
这些是指我在通用模块中具有的@JsName()
注释.
These are referring to the @JsName()
annotations I have within my common module.
我尝试过:
- 使用内置向导从头开始全新的MPP,并将
@JsName("test")
添加到生成的示例随附的hello()
函数中.即使那样似乎也会引起问题. - 使缓存无效/重新启动IntelliJ
- 使用所有组件的最新版本(Kotlin 1.3,IntelliJ IDEA 2018.2.5 Ultimate)
- 从命令行调用
./gradlew build
.这行得通.
- Starting a completely new MPP from scratch using the built-in wizard, and simply adding
@JsName("test")
to thehello()
function that comes with the generated sample. Even that seems to cause problems. - Invalidating caches/restarting IntelliJ
- Using the latest versions of everything (Kotlin 1.3, IntelliJ IDEA 2018.2.5 Ultimate)
- Calling
./gradlew build
from the command line. This works.
推荐答案
此问题已在IntelliJ的Kotlin插件的v1.3.10中修复.
This was fixed within v1.3.10 of the Kotlin plugin for IntelliJ.
这篇关于错误:带有@OptionalExpectation注释的声明只能在通用模块源中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!