FIR: support copy functions in data classes
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
data class Some(val x: Int, val y: String)
|
||||
|
||||
fun test(some: Some) {
|
||||
val other = some.copy(y = "123")
|
||||
val another = some.copy(x = 123)
|
||||
val same = some.copy()
|
||||
val different = some.copy(456, "456")
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
FILE: copy.kt
|
||||
public final data class Some : R|kotlin/Any| {
|
||||
public constructor(x: R|kotlin/Int|, y: R|kotlin/String|): R|Some| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/Int| = R|<local>/x|
|
||||
public get(): R|kotlin/Int|
|
||||
|
||||
public final val y: R|kotlin/String| = R|<local>/y|
|
||||
public get(): R|kotlin/String|
|
||||
|
||||
public final fun component1(): R|kotlin/Int| {
|
||||
^component1 R|/Some.x|
|
||||
}
|
||||
|
||||
public final fun component2(): R|kotlin/String| {
|
||||
^component2 R|/Some.y|
|
||||
}
|
||||
|
||||
public final fun copy(x: R|kotlin/Int| = R|/Some.x|, y: R|kotlin/String| = R|/Some.y|): R|Some| {
|
||||
^copy R|/Some.Some|(R|<local>/x|, R|<local>/y|)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test(some: R|Some|): R|kotlin/Unit| {
|
||||
lval other: R|Some| = R|<local>/some|.R|/Some.copy|(y = String(123))
|
||||
lval another: R|Some| = R|<local>/some|.R|/Some.copy|(x = Int(123))
|
||||
lval same: R|Some| = R|<local>/some|.R|/Some.copy|()
|
||||
lval different: R|Some| = R|<local>/some|.R|/Some.copy|(Int(456), String(456))
|
||||
}
|
||||
@@ -18,6 +18,10 @@ FILE: components.kt
|
||||
^component2 R|/D.y|
|
||||
}
|
||||
|
||||
public final fun copy(x: R|kotlin/Int| = R|/D.x|, y: R|kotlin/String| = R|/D.y|): R|D| {
|
||||
^copy R|/D.D|(R|<local>/x|, R|<local>/y|)
|
||||
}
|
||||
|
||||
}
|
||||
public final fun foo(list: R|kotlin/collections/List<D>|): R|kotlin/Unit| {
|
||||
lval <range>: R|kotlin/collections/List<D>| = R|<local>/list|
|
||||
|
||||
Reference in New Issue
Block a user