There is a code like this:
data class Vec2<T : Number>(val x : T, val y : T) { public operator fun plus(v : Vec2<T>) : Vec2<T> = Vec2(this.x + vx, this.y + vy); } The problem is that there are no Addable interfaces in Number, well, in descendants too. Is it possible to somehow avoid writing the implementation for each type separately?
The problem would be solved if it were possible to specify several possible types in the generic constraints (something like T: (Float | Int | Double)), or somehow check whether the required method is contained in the inline class (this is duck typing some)