Intellij Idea kotlin不能自动导入一些运算符函数,例如+
例如:
类common.number.Number.kt
:
operator fun Int.plus(other: BigInteger): BigInteger { return BigInteger(this.toString()).add(other) }
Class common.test.Test.kt
:
var i = 1 + BigInteger("1")
然后,Intellij Idea在Test.kt
类中显示错误。 但是,如果我添加以下导入,错误消失:
import common.number.Number.plus
我怎样才能让IntelliJ Idea自动导入这个操作函数?
因为做特别的扩展操作员所以需要。 它像扩展function一样工作。 需要导入,因为想法需要知道你想要使用哪个扩展名。 所以扩展可以多一个。
- 用Maven减少为Kotlin配置编译环境的时间
- arrayListOf和hashMapOf:未解析的引用
- 运行在Kotlin中编写的Apache Tomcat servlet时出错
- Docs for Spring告诉我,myRepository.findOne(Id id)返回实体,如果没有find,则返回null,但IntelliJ说不同
- Kotlin – IntelliJ项目设置
- KotlinJS中的Kootlin失败的世界没有定义
- 在使用maven时,Kotlin不是从src / main / kotlin编译的
- 尝试在IntelliJ IDEA中运行Kotlin脚本
- Kotlin NoClassDefFoundError和spring @RequestMapping方法