I'm unable to add two `BigInteger` s, both when I ...
# announcements
m
I'm unable to add two
BigInteger
s, both when I use
+
and
plus()
. I get a compiler error about overload ambiguity: <https://ss.nohus.eu/14331/03576c27> How to fix this error? This does not compile:
Copy code
fun main() {
    BigInteger.ONE + BigInteger.ONE
}
🤔 3
m
Where did you define your extension for the plus operator of
BigInteger
? You might have two definitions of it
m
I haven't, there is one by default in Kotlin (in
BigIntegers.kt
)
m
Oh, I didn’t know it was defined there, my bad. If you try to navigate to the source of the
+
sign, does it lead to two methods?
m
It leads to one, not sure how to find the second one, it seems the error points twice to the same one.
😕 2
b
try to 1. optimize imports (ctrl + alt + o) 2. type BigInteger.ONE.plus and look on autocomplete
m
Copy code
import java.math.BigInteger

fun main() {
    BigInteger.ONE.plus(BigInteger.ONE)
}
Same error, this is the entire file. Does it compile for other people? Any other ideas?
m
Works fine on my machine
Copy code
~ > kotlinc-jvm
Welcome to Kotlin version 1.3.61 (JRE 1.8.0_141-b15)
Type :help for help, :quit for quit
>>> import java.math.BigInteger
>>> BigInteger.ONE.plus(BigInteger.ONE)
res1: java.math.BigInteger = 2
t
This might be due to having multiple version of the Kotlin Stdlib in the classpath, hence the duplicate extension.