Add a couple more tests for array constructors and references

This commit is contained in:
pyos
2021-05-05 10:45:23 +02:00
committed by TeamCityServer
parent a30cfc332d
commit 1181854bd6
14 changed files with 88 additions and 6 deletions
@@ -0,0 +1,10 @@
// WITH_RUNTIME
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: PROPERTY_REFERENCES
fun foo(it: Int) = "O"[it]
val Int.foo: Char
get() = "K"[this]
fun box(): String =
CharArray(1, ::foo)[0].toString() + CharArray(1, Int::foo)[0].toString()
@@ -1,5 +1,6 @@
// WITH_RUNTIME
// DONT_TARGET_EXACT_BACKEND: WASM
// WASM_MUTE_REASON: BINDING_RECEIVERS
class C(val x: String) {
fun foo(i: Int): Char = x[i]
}
@@ -0,0 +1,16 @@
// WITH_RUNTIME
fun foo1(x: Int) = x
fun foo2(vararg x: Int) = x[0]
fun Int.foo3() = this
fun IntArray.foo4(x: Int) = this[x]
val Int.foo5 get() = this
fun test() {
// None of this should create any Function1 implementations because IntArray is inline.
IntArray(1, ::foo1)
IntArray(1, ::foo2)
IntArray(1, Int::foo3)
IntArray(1, intArrayOf(0)::foo4)
IntArray(1, Int::foo5)
}
@@ -0,0 +1,10 @@
@kotlin.Metadata
public final class CallableReferenceArrayConstructorArgumentsKt {
// source: 'callableReferenceArrayConstructorArguments.kt'
public final static method foo1(p0: int): int
public varargs final static method foo2(@org.jetbrains.annotations.NotNull p0: int[]): int
public final static method foo3(p0: int): int
public final static method foo4(@org.jetbrains.annotations.NotNull p0: int[], p1: int): int
public final static method getFoo5(p0: int): int
public final static method test(): void
}