无法添加BigInteger

当我试图执行下面的代码:

fun main(args: Array<String>) { val x = BigInteger.ONE var y = BigInteger.TEN val z = x + y; } 

我得到这个错误,有什么不对? 我正在使用1.0.0-beta-1038-IJ143-19

 Error:(7, 15) Kotlin: Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: public operator fun <T> kotlin.Array<???>.plus(array: kotlin.Array<out ???>): kotlin.Array<???> defined in kotlin public operator fun <T> kotlin.Array<???>.plus(collection: kotlin.Collection<???>): kotlin.Array<???> defined in kotlin public operator fun <T> kotlin.Array<java.math.BigInteger!>.plus(element: java.math.BigInteger!): kotlin.Array<java.math.BigInteger!> defined in kotlin public operator fun kotlin.BooleanArray.plus(element: kotlin.Boolean): kotlin.BooleanArray defined in kotlin public operator fun kotlin.BooleanArray.plus(array: kotlin.BooleanArray): kotlin.BooleanArray defined in kotlin public operator fun kotlin.BooleanArray.plus(collection: kotlin.Collection<kotlin.Boolean>): kotlin.BooleanArray defined in kotlin public operator fun kotlin.ByteArray.plus(element: kotlin.Byte): kotlin.ByteArray defined in kotlin public operator fun kotlin.ByteArray.plus(array: kotlin.ByteArray): kotlin.ByteArray defined in kotlin public operator fun kotlin.ByteArray.plus(collection: kotlin.Collection<kotlin.Byte>): kotlin.ByteArray defined in kotlin public operator fun kotlin.Char.plus(string: kotlin.String): kotlin.String defined in kotlin public operator fun kotlin.CharArray.plus(element: kotlin.Char): kotlin.CharArray defined in kotlin public operator fun kotlin.CharArray.plus(array: kotlin.CharArray): kotlin.CharArray defined in kotlin public operator fun kotlin.CharArray.plus(collection: kotlin.Collection<kotlin.Char>): kotlin.CharArray defined in kotlin public operator fun <T> kotlin.Collection<???>.plus(array: kotlin.Array<out ???>): kotlin.List<???> defined in kotlin public operator fun <T> kotlin.Collection<???>.plus(collection: kotlin.Iterable<???>): kotlin.List<???> defined in kotlin public operator fun <T> kotlin.Collection<???>.plus(sequence: kotlin.Sequence<???>): kotlin.List<???> defined in kotlin public operator fun <T> kotlin.Collection<java.math.BigInteger!>.plus(element: java.math.BigInteger!): kotlin.List<java.math.BigInteger!> defined in kotlin public operator fun kotlin.DoubleArray.plus(collection: kotlin.Collection<kotlin.Double>): kotlin.DoubleArray defined in kotlin public operator fun kotlin.DoubleArray.plus(element: kotlin.Double): kotlin.DoubleArray defined in kotlin public operator fun kotlin.DoubleArray.plus(array: kotlin.DoubleArray): kotlin.DoubleArray defined in kotlin public operator fun kotlin.FloatArray.plus(collection: kotlin.Collection<kotlin.Float>): kotlin.FloatArray defined in kotlin public operator fun kotlin.FloatArray.plus(element: kotlin.Float): kotlin.FloatArray defined in kotlin public operator fun kotlin.FloatArray.plus(array: kotlin.FloatArray): kotlin.FloatArray defined in kotlin public operator fun kotlin.IntArray.plus(collection: kotlin.Collection<kotlin.Int>): kotlin.IntArray defined in kotlin public operator fun kotlin.IntArray.plus(element: kotlin.Int): kotlin.IntArray defined in kotlin public operator fun kotlin.IntArray.plus(array: kotlin.IntArray): kotlin.IntArray defined in kotlin public operator fun <T> kotlin.Iterable<???>.plus(array: kotlin.Array<out ???>): kotlin.List<???> defined in kotlin public operator fun <T> kotlin.Iterable<???>.plus(collection: kotlin.Iterable<???>): kotlin.List<???> defined in kotlin public operator fun <T> kotlin.Iterable<???>.plus(sequence: kotlin.Sequence<???>): kotlin.List<???> defined in kotlin public operator fun <T> kotlin.Iterable<java.math.BigInteger!>.plus(element: java.math.BigInteger!): kotlin.List<java.math.BigInteger!> defined in kotlin public operator fun kotlin.LongArray.plus(collection: kotlin.Collection<kotlin.Long>): kotlin.LongArray defined in kotlin public operator fun kotlin.LongArray.plus(element: kotlin.Long): kotlin.LongArray defined in kotlin public operator fun kotlin.LongArray.plus(array: kotlin.LongArray): kotlin.LongArray defined in kotlin public operator fun <K, V> kotlin.Map<???, ???>.plus(pairs: kotlin.Array<kotlin.Pair<???, ???>>): kotlin.Map<???, ???> defined in kotlin public operator fun <K, V> kotlin.Map<???, ???>.plus(pairs: kotlin.Iterable<kotlin.Pair<???, ???>>): kotlin.Map<???, ???> defined in kotlin public operator fun <K, V> kotlin.Map<???, ???>.plus(map: kotlin.Map<???, ???>): kotlin.Map<???, ???> defined in kotlin public operator fun <K, V> kotlin.Map<???, ???>.plus(pair: kotlin.Pair<???, ???>): kotlin.Map<???, ???> defined in kotlin public operator fun <K, V> kotlin.Map<???, ???>.plus(pairs: kotlin.Sequence<kotlin.Pair<???, ???>>): kotlin.Map<???, ???> defined in kotlin public operator fun <T> kotlin.Sequence<???>.plus(array: kotlin.Array<out ???>): kotlin.Sequence<???> defined in kotlin public operator fun <T> kotlin.Sequence<???>.plus(collection: kotlin.Iterable<???>): kotlin.Sequence<???> defined in kotlin public operator fun <T> kotlin.Sequence<???>.plus(sequence: kotlin.Sequence<???>): kotlin.Sequence<???> defined in kotlin public operator fun <T> kotlin.Sequence<java.math.BigInteger!>.plus(element: java.math.BigInteger!): kotlin.Sequence<java.math.BigInteger!> defined in kotlin public operator fun <T> kotlin.Set<???>.plus(array: kotlin.Array<out ???>): kotlin.Set<???> defined in kotlin public operator fun <T> kotlin.Set<???>.plus(collection: kotlin.Iterable<???>): kotlin.Set<???> defined in kotlin public operator fun <T> kotlin.Set<???>.plus(sequence: kotlin.Sequence<???>): kotlin.Set<???> defined in kotlin public operator fun <T> kotlin.Set<java.math.BigInteger!>.plus(element: java.math.BigInteger!): kotlin.Set<java.math.BigInteger!> defined in kotlin public operator fun kotlin.ShortArray.plus(collection: kotlin.Collection<kotlin.Short>): kotlin.ShortArray defined in kotlin public operator fun kotlin.ShortArray.plus(element: kotlin.Short): kotlin.ShortArray defined in kotlin public operator fun kotlin.ShortArray.plus(array: kotlin.ShortArray): kotlin.ShortArray defined in kotlin public operator fun kotlin.String?.plus(other: kotlin.Any?): kotlin.String defined in kotlin 

它不能解决加上操作员http://kotlinlang.org/api/latest/jvm/stdlib/kotlin.math/-big-integer/plus.html
添加一个导入可以修复它: import kotlin.math.*

至于这个奇怪的行为,有两个问题:
1)是否应该默认导入? 如果是这样,这是一个错误。
2)IDEA是否显示自动导入的意图? 如果没有,那是一个错误。

无论哪种方式,请报告https://youtrack.jetbrains.com/issues/KT

Kotlin进口是隐含的,不需要添加。 通常这样的错误是当你的插件版本是Kotlin的一个版本时,你项目中的IntelliJ IDEA缓存或库版本是另一个版本。 您的IDE中可能会有另一个错误消息,告诉您Kotlin库与插件版本不匹配。 发生这种情况时请检查

  1. Kotlin的IDE插件版本与该项目使用的库相同(Kotlin Betas现在不那么重要,可以更持续地保持二进制兼容性)

  2. 在IDE中清除缓存,可以在IntelliJ IDEA中找到“File – > Invalidate Caches and Restart”菜单项并选择该选项并重新启动。

  3. 您的类路径中实际上包含Kotlin运行时JAR。

这个问题没有错误。 这是上述问题之一。