[IR] add testdata for dumpKotlinLike
This commit is contained in:
committed by
teamcityserver
parent
d2022ab115
commit
8d5facb15f
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
fun use(f: @ExtensionFunctionType Function2<C, Int, Unit>) {
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun C.extensionVararg(i: Int, vararg s: String) {
|
||||
}
|
||||
|
||||
fun C.extensionDefault(i: Int, s: String = "") {
|
||||
}
|
||||
|
||||
fun C.extensionBoth(i: Int, s: String = "", vararg t: String) {
|
||||
}
|
||||
|
||||
fun testExtensionVararg() {
|
||||
use(f = local fun extensionVararg(p0: C, p1: Int) {
|
||||
extensionVararg($receiver = p0, i = p1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testExtensionDefault() {
|
||||
use(f = local fun extensionDefault(p0: C, p1: Int) {
|
||||
extensionDefault($receiver = p0, i = p1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testExtensionBoth() {
|
||||
use(f = local fun extensionBoth(p0: C, p1: Int) {
|
||||
extensionBoth($receiver = p0, i = p1)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
fun useUnit0(fn: Function0<Unit>) {
|
||||
}
|
||||
|
||||
fun useUnit1(fn: Function1<Int, Unit>) {
|
||||
}
|
||||
|
||||
fun fn0(): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun fn1(x: Int): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun fnv(vararg xs: Int): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun test0() {
|
||||
return useUnit0(fn = local fun fn0() {
|
||||
fn0() /*~> Unit */
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
return useUnit1(fn = local fun fn1(p0: Int) {
|
||||
fn1(x = p0) /*~> Unit */
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testV0() {
|
||||
return useUnit0(fn = local fun fnv() {
|
||||
fnv() /*~> Unit */
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testV1() {
|
||||
return useUnit1(fn = local fun fnv(p0: Int) {
|
||||
fnv(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Vendored
+20
@@ -0,0 +1,20 @@
|
||||
package test
|
||||
|
||||
inline fun foo(x: Function0<Unit>) {
|
||||
}
|
||||
|
||||
fun String.id(s: String = <this>, vararg xs: Int): String {
|
||||
return s
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo(x = { //BLOCK
|
||||
local fun String.id() {
|
||||
id($receiver = receiver, ) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
::id
|
||||
})
|
||||
}
|
||||
|
||||
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
package test
|
||||
|
||||
class Foo<T : Any?> {
|
||||
constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
inner class Inner<P : Any?> {
|
||||
constructor(a: T, b: P) /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
val a: T
|
||||
field = a
|
||||
get
|
||||
|
||||
val b: P
|
||||
field = b
|
||||
get
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline fun <A : Any?, B : Any?> foo(a: A, b: B, x: Function2<A, B, Inner<B, A>>): Inner<B, A> {
|
||||
return x.invoke(p1 = a, p2 = b)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val z: Foo<String> = TODO("IrConstructorCall")
|
||||
val foo: Inner<String, String> = foo<String, String>(a = "O", b = "K", x = ::<init>)
|
||||
return foo.<get-a>().plus(other = foo.<get-b>())
|
||||
}
|
||||
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
fun interface IFoo {
|
||||
abstract fun foo(i: Int)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun interface IFoo2 : IFoo {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
object A {
|
||||
private constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
object B {
|
||||
private constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
operator fun A.get(i: IFoo): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
operator fun A.set(i: IFoo, newValue: Int) {
|
||||
}
|
||||
|
||||
operator fun B.get(i: IFoo): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
operator fun B.set(i: IFoo2, newValue: Int) {
|
||||
}
|
||||
|
||||
fun withVararg(vararg xs: Int): Int {
|
||||
return 42
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
{ //BLOCK
|
||||
val tmp0_array: A = A
|
||||
val tmp2_sam: IFoo = local fun withVararg(p0: Int) {
|
||||
withVararg(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
/*-> IFoo */
|
||||
set($receiver = tmp0_array, i = tmp2_sam, newValue = get($receiver = tmp0_array, i = tmp2_sam).plus(other = 1))
|
||||
}
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
{ //BLOCK
|
||||
val tmp0_array: B = B
|
||||
val tmp2_sam: IFoo2 = local fun withVararg(p0: Int) {
|
||||
withVararg(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
/*-> IFoo2 */
|
||||
set($receiver = tmp0_array, i = tmp2_sam, newValue = get($receiver = tmp0_array, i = tmp2_sam).plus(other = 1))
|
||||
}
|
||||
}
|
||||
|
||||
fun test3(fn: Function1<Int, Unit>) {
|
||||
{ //BLOCK
|
||||
val tmp0_array: A = A
|
||||
val tmp2_sam: IFoo = fn /*-> IFoo */
|
||||
set($receiver = tmp0_array, i = tmp2_sam, newValue = get($receiver = tmp0_array, i = tmp2_sam).plus(other = 1))
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(fn: Function1<Int, Unit>) {
|
||||
when {
|
||||
fn is IFoo -> { //BLOCK
|
||||
{ //BLOCK
|
||||
val tmp0_array: A = A
|
||||
val tmp1_index0: Function1<Int, Unit> = fn
|
||||
set($receiver = tmp0_array, i = tmp1_index0 /*as IFoo */, newValue = get($receiver = tmp0_array, i = tmp1_index0 /*as IFoo */).plus(other = 1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(a: Any) {
|
||||
a as Function1<Int, Unit> /*~> Unit */
|
||||
{ //BLOCK
|
||||
val tmp0_array: A = A
|
||||
val tmp2_sam: IFoo = a /*as Function1<@ParameterName(...) Int, Unit> */ /*-> IFoo */
|
||||
set($receiver = tmp0_array, i = tmp2_sam, newValue = get($receiver = tmp0_array, i = tmp2_sam).plus(other = 1))
|
||||
}
|
||||
}
|
||||
|
||||
fun test6(a: Any) {
|
||||
a as Function1<Int, Unit> /*~> Unit */
|
||||
a as IFoo /*~> Unit */
|
||||
{ //BLOCK
|
||||
val tmp0_array: A = A
|
||||
val tmp1_index0: Any = a
|
||||
set($receiver = tmp0_array, i = tmp1_index0 /*as IFoo */, newValue = get($receiver = tmp0_array, i = tmp1_index0 /*as IFoo */).plus(other = 1))
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+70
@@ -0,0 +1,70 @@
|
||||
fun use(fn: Function1<Int, Any>): Any {
|
||||
return fn.invoke(p1 = 42)
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor(vararg xs: Int) /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
class Outer {
|
||||
constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
inner class Inner {
|
||||
constructor(vararg xs: Int) /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun testConstructor(): Any {
|
||||
return use(fn = local fun <init>(p0: Int): C {
|
||||
return TODO("IrConstructorCall")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testInnerClassConstructor(outer: Outer): Any {
|
||||
return use(fn = { //BLOCK
|
||||
local fun Outer.<init>(p0: Int): Inner {
|
||||
return TODO("IrConstructorCall")
|
||||
}
|
||||
|
||||
|
||||
::<init>
|
||||
})
|
||||
}
|
||||
|
||||
fun testInnerClassConstructorCapturingOuter(): Any {
|
||||
return use(fn = { //BLOCK
|
||||
val tmp0_receiver: Outer = TODO("IrConstructorCall")
|
||||
local fun Outer.<init>(p0: Int): Inner {
|
||||
return TODO("IrConstructorCall")
|
||||
}
|
||||
|
||||
|
||||
::<init>
|
||||
})
|
||||
}
|
||||
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
fun defaultsOnly(x: String = ""): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun regularAndDefaults(x1: String, x2: String = ""): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
fun varargs(vararg xs: String): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor(x: String = "") /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
val x: String
|
||||
field = x
|
||||
get
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun useKCallableStar(fn: KCallable<*>) {
|
||||
}
|
||||
|
||||
fun testDefaultsOnlyStar() {
|
||||
useKCallableStar(fn = ::defaultsOnly)
|
||||
}
|
||||
|
||||
fun testRegularAndDefaultsStar() {
|
||||
useKCallableStar(fn = ::regularAndDefaults)
|
||||
}
|
||||
|
||||
fun testVarargsStar() {
|
||||
useKCallableStar(fn = ::varargs)
|
||||
}
|
||||
|
||||
fun testCtorStar() {
|
||||
useKCallableStar(fn = ::<init>)
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
class A<T : Any?> {
|
||||
constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
|
||||
val bar: Int
|
||||
field = 42
|
||||
get
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
val test1: KFunction1<A<String>, Unit>
|
||||
field = ::foo
|
||||
get
|
||||
|
||||
val test2: KProperty1<A<String>, Int>
|
||||
field = ::bar
|
||||
get
|
||||
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package test
|
||||
|
||||
object Foo {
|
||||
private constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
val a: String
|
||||
field = ""
|
||||
get
|
||||
|
||||
fun foo(): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
val test1: KProperty0<String>
|
||||
field = ::a
|
||||
get
|
||||
|
||||
val test1a: KProperty0<String>
|
||||
field = ::a
|
||||
get
|
||||
|
||||
val test2: KFunction0<String>
|
||||
field = ::foo
|
||||
get
|
||||
|
||||
val test2a: KFunction0<String>
|
||||
field = ::foo
|
||||
get
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
fun foo(x: String = ""): String {
|
||||
return x
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor(x: String = "") /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
val x: String
|
||||
field = x
|
||||
get
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun use(fn: Function0<Any>): Any {
|
||||
return fn.invoke()
|
||||
}
|
||||
|
||||
fun testFn(): Any {
|
||||
return use(fn = local fun foo(): String {
|
||||
return foo()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testCtor(): Any {
|
||||
return use(fn = local fun <init>(): C {
|
||||
return TODO("IrConstructorCall")
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
+105
@@ -0,0 +1,105 @@
|
||||
fun useSuspend(fn: SuspendFunction0<Unit>) {
|
||||
}
|
||||
|
||||
fun useSuspendInt(fn: SuspendFunction1<Int, Unit>) {
|
||||
}
|
||||
|
||||
suspend fun foo0() {
|
||||
}
|
||||
|
||||
fun foo1() {
|
||||
}
|
||||
|
||||
fun fooInt(x: Int) {
|
||||
}
|
||||
|
||||
fun foo2(vararg xs: Int) {
|
||||
}
|
||||
|
||||
fun foo3(): Int {
|
||||
return 42
|
||||
}
|
||||
|
||||
fun foo4(i: Int = 42) {
|
||||
}
|
||||
|
||||
class C {
|
||||
constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
fun bar() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun testLambda() {
|
||||
useSuspend(fn = local suspend fun <anonymous>() {
|
||||
foo1()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testNoCoversion() {
|
||||
useSuspend(fn = ::foo0)
|
||||
}
|
||||
|
||||
fun testSuspendPlain() {
|
||||
useSuspend(fn = local suspend fun foo1() {
|
||||
foo1()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testSuspendWithArgs() {
|
||||
useSuspendInt(fn = local suspend fun fooInt(p0: Int) {
|
||||
fooInt(x = p0)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testWithVararg() {
|
||||
useSuspend(fn = local suspend fun foo2() {
|
||||
foo2()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testWithVarargMapped() {
|
||||
useSuspendInt(fn = local suspend fun foo2(p0: Int) {
|
||||
foo2(xs = [p0])
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testWithCoercionToUnit() {
|
||||
useSuspend(fn = local suspend fun foo3() {
|
||||
foo3() /*~> Unit */
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testWithDefaults() {
|
||||
useSuspend(fn = local suspend fun foo4() {
|
||||
foo4()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testWithBoundReceiver() {
|
||||
useSuspend(fn = { //BLOCK
|
||||
val tmp0_receiver: C = TODO("IrConstructorCall")
|
||||
local suspend fun C.bar() {
|
||||
receiver.bar()
|
||||
}
|
||||
|
||||
|
||||
::bar
|
||||
})
|
||||
}
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
object Host {
|
||||
private constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
inline fun <reified T : Any?> objectMember(x: T) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
inline fun <reified T : Any?> topLevel1(x: T) {
|
||||
}
|
||||
|
||||
inline fun <reified T : Any?> topLevel2(x: List<T>) {
|
||||
}
|
||||
|
||||
val test1: Function1<Int, Unit>
|
||||
field = ::topLevel1
|
||||
get
|
||||
|
||||
val test2: Function1<List<String>, Unit>
|
||||
field = ::topLevel2
|
||||
get
|
||||
|
||||
val test3: Function1<Int, Unit>
|
||||
field = ::objectMember
|
||||
get
|
||||
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
fun use1(fn: Function2<A, Int, Unit>) {
|
||||
}
|
||||
|
||||
fun use2(fn: Function1<Int, Unit>) {
|
||||
}
|
||||
|
||||
open class A {
|
||||
constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
open fun foo(vararg xs: Int): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
object Obj : A {
|
||||
private constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
override fun foo(vararg xs: Int): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun testUnbound() {
|
||||
use1(fn = local fun foo(p0: A, p1: Int) {
|
||||
p0.foo(xs = [p1]) /*~> Unit */
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testBound(a: A) {
|
||||
use2(fn = { //BLOCK
|
||||
local fun A.foo(p0: Int) {
|
||||
receiver.foo(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
::foo
|
||||
})
|
||||
}
|
||||
|
||||
fun testObject() {
|
||||
use2(fn = { //BLOCK
|
||||
local fun Obj.foo(p0: Int) {
|
||||
receiver.foo(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
::foo
|
||||
})
|
||||
}
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
fun interface IFoo {
|
||||
abstract fun foo(i: Int)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun useFoo(foo: IFoo) {
|
||||
}
|
||||
|
||||
fun withVararg(vararg xs: Int): Int {
|
||||
return 42
|
||||
}
|
||||
|
||||
fun test() {
|
||||
useFoo(foo = local fun withVararg(p0: Int) {
|
||||
withVararg(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
/*-> IFoo */)
|
||||
}
|
||||
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
fun use(fn: Function1<Int, String>): String {
|
||||
return fn.invoke(p1 = 1)
|
||||
}
|
||||
|
||||
fun use0(fn: Function0<String>): String {
|
||||
return fn.invoke()
|
||||
}
|
||||
|
||||
fun coerceToUnit(fn: Function1<Int, Unit>) {
|
||||
}
|
||||
|
||||
fun fnWithDefault(a: Int, b: Int = 42): String {
|
||||
return "abc"
|
||||
}
|
||||
|
||||
fun fnWithDefaults(a: Int = 1, b: Int = 2): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
fun fnWithVarargs(vararg xs: Int): String {
|
||||
return "abc"
|
||||
}
|
||||
|
||||
object Host {
|
||||
private constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
fun importedObjectMemberWithVarargs(vararg xs: Int): String {
|
||||
return "abc"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun testDefault(): String {
|
||||
return use(fn = local fun fnWithDefault(p0: Int): String {
|
||||
return fnWithDefault(a = p0)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testVararg(): String {
|
||||
return use(fn = local fun fnWithVarargs(p0: Int): String {
|
||||
return fnWithVarargs(xs = [p0])
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testCoercionToUnit() {
|
||||
return coerceToUnit(fn = local fun fnWithDefault(p0: Int) {
|
||||
fnWithDefault(a = p0) /*~> Unit */
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testImportedObjectMember(): String {
|
||||
return use(fn = { //BLOCK
|
||||
local fun importedObjectMemberWithVarargs(p0: Int): String {
|
||||
return importedObjectMemberWithVarargs(xs = [p0])
|
||||
}
|
||||
|
||||
|
||||
::importedObjectMemberWithVarargs
|
||||
})
|
||||
}
|
||||
|
||||
fun testDefault0(): String {
|
||||
return use0(fn = local fun fnWithDefaults(): String {
|
||||
return fnWithDefaults()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testVararg0(): String {
|
||||
return use0(fn = local fun fnWithVarargs(): String {
|
||||
return fnWithVarargs()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Vendored
+79
@@ -0,0 +1,79 @@
|
||||
fun use(fn: Function1<Int, Unit>) {
|
||||
fn.invoke(p1 = 1)
|
||||
}
|
||||
|
||||
class Host {
|
||||
constructor() /* primary */ {
|
||||
TODO("IrDelegatingConstructorCall")
|
||||
/* InstanceInitializerCall */
|
||||
|
||||
}
|
||||
|
||||
fun withVararg(vararg xs: Int): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
fun testImplicitThis() {
|
||||
use(fn = { //BLOCK
|
||||
local fun Host.withVararg(p0: Int) {
|
||||
receiver.withVararg(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
::withVararg
|
||||
})
|
||||
}
|
||||
|
||||
fun testBoundReceiverLocalVal() {
|
||||
val h: Host = TODO("IrConstructorCall")
|
||||
use(fn = { //BLOCK
|
||||
local fun Host.withVararg(p0: Int) {
|
||||
receiver.withVararg(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
::withVararg
|
||||
})
|
||||
}
|
||||
|
||||
fun testBoundReceiverLocalVar() {
|
||||
var h: Host = TODO("IrConstructorCall")
|
||||
use(fn = { //BLOCK
|
||||
val tmp0_receiver: Host = h
|
||||
local fun Host.withVararg(p0: Int) {
|
||||
receiver.withVararg(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
::withVararg
|
||||
})
|
||||
}
|
||||
|
||||
fun testBoundReceiverParameter(h: Host) {
|
||||
use(fn = { //BLOCK
|
||||
local fun Host.withVararg(p0: Int) {
|
||||
receiver.withVararg(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
::withVararg
|
||||
})
|
||||
}
|
||||
|
||||
fun testBoundReceiverExpression() {
|
||||
use(fn = { //BLOCK
|
||||
val tmp0_receiver: Host = TODO("IrConstructorCall")
|
||||
local fun Host.withVararg(p0: Int) {
|
||||
receiver.withVararg(xs = [p0]) /*~> Unit */
|
||||
}
|
||||
|
||||
|
||||
::withVararg
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+53
@@ -0,0 +1,53 @@
|
||||
fun sum(vararg args: Int): Int {
|
||||
var result: Int = 0
|
||||
{ //BLOCK
|
||||
val tmp0_iterator: IntIterator = args.iterator()
|
||||
while (tmp0_iterator.hasNext()) { //BLOCK
|
||||
val arg: Int = tmp0_iterator.next()
|
||||
result = result.plus(other = arg)
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
fun nsum(vararg args: Number): Int {
|
||||
return sum(args = [*TODO("IrConstructorCall")])
|
||||
}
|
||||
|
||||
fun zap(vararg b: String, k: Int = 42) {
|
||||
}
|
||||
|
||||
fun usePlainArgs(fn: Function2<Int, Int, Int>) {
|
||||
}
|
||||
|
||||
fun usePrimitiveArray(fn: Function1<IntArray, Int>) {
|
||||
}
|
||||
|
||||
fun useArray(fn: Function1<Array<Int>, Int>) {
|
||||
}
|
||||
|
||||
fun useStringArray(fn: Function1<Array<String>, Unit>) {
|
||||
}
|
||||
|
||||
fun testPlainArgs() {
|
||||
usePlainArgs(fn = local fun sum(p0: Int, p1: Int): Int {
|
||||
return sum(args = [p0, p1])
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
fun testPrimitiveArrayAsVararg() {
|
||||
usePrimitiveArray(fn = ::sum)
|
||||
}
|
||||
|
||||
fun testArrayAsVararg() {
|
||||
useArray(fn = ::nsum)
|
||||
}
|
||||
|
||||
fun testArrayAndDefaults() {
|
||||
useStringArray(fn = local fun zap(p0: Array<out String>) {
|
||||
zap(b = [*p0])
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user