Kotlin:Kotlin脚本(.kts)不能使用常规代码吗? [英] Kotlin: Kotlin-script (.kts) cannot use regular code?
本文介绍了Kotlin:Kotlin脚本(.kts)不能使用常规代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的库的代码库中,我具有以下打包功能:fun sayHello() = println("Hello there!")
该功能在包org.jire.pomade
In my library's codebase, I have this package function: fun sayHello() = println("Hello there!")
The function is defined in the package org.jire.pomade
我想在 .kts 文件中使用此功能,如下所示:sayHello()
I would like to use this function in a .kts file like so: sayHello()
不幸的是,我似乎无法从Kotlin自己的stdlib中分离出代码来在Kotlin脚本文件中工作.
Unfortunately I can't seem to get code apart from Kotlin's own stdlib to work in Kotlin-script files.
我的整个脚本:
import org.jire.pomade.sayHello
sayHello()
运行脚本的结果:
pomade.kts:1:12: error: unresolved reference: jire
import org.jire.pomade.sayHello
^
pomade.kts:3:1: error: unresolved reference: sayHello
sayHello()
^
有人知道为什么会这样吗?谢谢.
Anybody know why this is happening? Thanks.
推荐答案
This is a bug in the Kotlin plugin: https://youtrack.jetbrains.com/issue/KT-11618
这篇关于Kotlin:Kotlin脚本(.kts)不能使用常规代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文