Guys is there any chance to declare operators with...
# announcements
a
Guys is there any chance to declare operators with generic number types? I want something like this:
Copy code
class Vector2<T : Number>(val x: T, val y: T) {

    operator fun plus(vector2: Vector2<Number>): Vector2<T> {
        return Vector2(x + vector2.x, y + vector2.y) // Doesn't compile
    }
}

fun main(args: Array<String>) {
    Vector2(1, 1) + Vector2(2, 2) // Int
    Vector2(1.0, 1.0) + Vector2(2.0, 2.0) // Double
    Vector2(1, 1) + Vector2(2.0, 2.0) // Ideally second Vector2 type should be casted toInt() here
}
But it'm not sure how to do it