JVM_IR KT-45187 use Arrays.copyOf to copy an array in spread operator

Creating a new array (and copying data into it with System.arraycopy)
doesn't work in generic case, because the actual array class depends on
call site.
This commit is contained in:
Dmitry Petrov
2021-04-13 14:35:18 +03:00
committed by TeamCityServer
parent 334d0a8b5a
commit 7d62f0b5aa
10 changed files with 192 additions and 23 deletions
+13
View File
@@ -0,0 +1,13 @@
// TARGET_BACKEND: JVM
fun box(): String =
object : A<Void, Void>() {
override fun f(vararg params: Void): Void? = null
}.execute()
abstract class A<P, R> {
protected abstract fun f(vararg params: P): R?
fun execute(vararg params: P): String =
if (f(*params) == null) "OK" else "Fail"
}