I have a kotlin math lib with the following Vec2i
class and primary constructor:
data class Vec2i(override var x: Int, override var y: Int) : Vec2t<Int>()
Then Vec2i
has also, among several secondary constructors, one which is supposed to intercept all the other number types:
constructor(x: Number, y: Number) : this(x.i, y.i)
Everything under Idea compiles and runs. I tested the artifact with a separate java project.
The same artifact doesn't run in a java project if I switch IDE, Netbeans complains about ambiguity between the two.
Why?
Edit: from some further analysis, it turned out Netbeans complains because one of coordinate was int
, the other Integer
.
Trying the same on Idea, it says:
cannot resolve constructor
So, why calling a costructor with (int, int)
or (Integer, Integer)
is fine, but (int, Integer)
doesn't resolved to the secondary constructor and provoke ambiguity?