gpt4 book ai didi

kotlin - 无法执行BigInteger的添加

转载 作者:行者123 更新时间:2023-12-01 10:10:05 33 4
gpt4 key购买 nike

当我尝试执行以下代码时:

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 - 无法执行BigInteger的添加,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33387657/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com