No, it doesn’t. Kotlin doesn’t have implicit type conversion. There is one exception with number literals.
So val foo: Long = 1
is ok even though 1
as a literal generally is of type Int
.
This is indeed done by operator overloading. The reason you can’t find the implementations is that they are directly translated into the specific jvm bytecode instructions. I don’t know the compiler well enough to point to a specific file (if this is even possible).
Yes. The standard library contains a plus
method for each combination of Number
types. If you were to add a new class extending Number
you would need to provide your own implementations of those functions or you couldn’t use mathmatical operators.