Files
kotlin-fork/compiler/testData/psi/examples/UpdateOperation.kt
T
Pavel V. Talanov 59f192ef90 Replace 'class object' with 'default object' in renderers and test data
Includes changes to decompiled text
Old syntax is used in builtins and project code for now
2015-03-06 19:36:54 +03:00

14 lines
369 B
Kotlin

class Pair(x : Int, y : Int) {
default object {
fun copy(from : Pair, x : Int = from.x, y : Int = from.y) = Pair(x, y)
}
}
// One can say:
val p = Point(1, 2)
val p1 = Point.Copy(p, x = 2)
val p2 = Point.Copy(p1, y = -1)
val p3 = Point.Copy(p)
// Such copy(...) methods can be automatically generated by the compiler
// whenever there is a primary constructor