[IR] add testdata for dumpKotlinLike

This commit is contained in:
Zalim Bashorov
2020-11-05 02:47:53 +03:00
committed by teamcityserver
parent d2022ab115
commit 8d5facb15f
365 changed files with 15516 additions and 0 deletions
@@ -0,0 +1,58 @@
fun interface IRunnable {
abstract fun run()
}
fun foo1(r: IRunnable, vararg s: String) {
}
fun foo2(r1: IRunnable, r2: IRunnable, vararg s: String) {
}
fun test(fn: Function0<Unit>, r: IRunnable, s: String, arr: Array<String>) {
foo1(r = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, s = [s])
foo1(r = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, s = [*arr])
foo1(r = fn /*-> IRunnable */, s = [s])
foo1(r = fn /*-> IRunnable */, s = [*arr])
foo1(r = r, s = [s])
foo1(r = r, s = [*arr])
foo2(r1 = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, r2 = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, s = [s])
foo2(r1 = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, r2 = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, s = [*arr])
foo2(r1 = fn /*-> IRunnable */, r2 = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, s = [s])
foo2(r1 = fn /*-> IRunnable */, r2 = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, s = [*arr])
foo2(r1 = r, r2 = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, s = [s])
foo2(r1 = r, r2 = local fun <anonymous>() {
return Unit
}
/*-> IRunnable */, s = [*arr])
}
@@ -0,0 +1,18 @@
fun interface Foo {
abstract fun invoke(): String
}
fun foo(f: Foo): String {
return f.invoke()
}
fun test(): String {
return foo(f = local fun <anonymous>(): String {
return "OK"
}
/*-> Foo */)
}
@@ -0,0 +1,12 @@
fun interface KRunnable {
abstract fun invoke()
}
fun test(a: Any?) {
a as Function0<Unit> /*~> Unit */
a /*as Function0<Unit> */ /*-> KRunnable */.invoke()
}
@@ -0,0 +1,80 @@
fun interface Fn<T : Any?, R : Any?> {
abstract fun run(s: String, i: Int, t: T): R
}
class J {
constructor() /* primary */ {
TODO("IrDelegatingConstructorCall")
/* InstanceInitializerCall */
}
fun runConversion(f1: Fn<String, Int>, f2: Fn<Int, String>): Int {
return f1.run(s = "Bar", i = 1, t = f2.run(s = "Foo", i = 42, t = 239))
}
}
val fsi: Fn<String, Int>
field = { //BLOCK
local class <no name provided> : Fn<String, Int> {
constructor() /* primary */ {
TODO("IrDelegatingConstructorCall")
/* InstanceInitializerCall */
}
override fun run(s: String, i: Int, t: String): Int {
return 1
}
}
TODO("IrConstructorCall")
}
get
val fis: Fn<Int, String>
field = { //BLOCK
local class <no name provided> : Fn<Int, String> {
constructor() /* primary */ {
TODO("IrDelegatingConstructorCall")
/* InstanceInitializerCall */
}
override fun run(s: String, i: Int, t: Int): String {
return ""
}
}
TODO("IrConstructorCall")
}
get
fun test(j: J) {
j.runConversion(f1 = <get-fsi>(), f2 = local fun <anonymous>(s: String, i: Int, ti: Int): String {
return ""
}
/*-> Fn<Int, String> */) /*~> Unit */
j.runConversion(f1 = local fun <anonymous>(s: String, i: Int, ts: String): Int {
return 1
}
/*-> Fn<String, Int> */, f2 = <get-fis>()) /*~> Unit */
}
@@ -0,0 +1,41 @@
fun interface IFoo {
abstract fun foo(i: Int)
}
fun useVararg(vararg foos: IFoo) {
}
fun testLambda() {
useVararg(foos = [ local fun <anonymous>(it: Int) {
return Unit
}
/*-> IFoo */])
}
fun testSeveralLambdas() {
useVararg(foos = [ local fun <anonymous>(it: Int) {
return Unit
}
/*-> IFoo */, local fun <anonymous>(it: Int) {
return Unit
}
/*-> IFoo */, local fun <anonymous>(it: Int) {
return Unit
}
/*-> IFoo */])
}
fun withVarargOfInt(vararg xs: Int): String {
return ""
}
fun testAdaptedCR() {
useVararg(foos = [ local fun withVarargOfInt(p0: Int) {
withVarargOfInt(xs = [p0]) /*~> Unit */
}
/*-> IFoo */])
}
@@ -0,0 +1,21 @@
fun interface MyRunnable {
abstract fun run()
}
fun test(a: Any, r: MyRunnable) {
when {
a is MyRunnable -> { //BLOCK
foo(rs = [ local fun <anonymous>() {
return Unit
}
/*-> MyRunnable */, r, a /*as MyRunnable */])
}
}
}
fun foo(vararg rs: MyRunnable) {
}
@@ -0,0 +1,39 @@
fun interface KRunnable {
abstract fun run()
}
fun foo0() {
}
fun foo1(vararg xs: Int): Int {
return 1
}
fun use(r: KRunnable) {
}
fun testSamConstructor(): KRunnable {
return ::foo0 /*-> KRunnable */
}
fun testSamCosntructorOnAdapted(): KRunnable {
return local fun foo1() {
foo1() /*~> Unit */
}
/*-> KRunnable */
}
fun testSamConversion() {
use(r = ::foo0 /*-> KRunnable */)
}
fun testSamConversionOnAdapted() {
use(r = local fun foo1() {
foo1() /*~> Unit */
}
/*-> KRunnable */)
}
@@ -0,0 +1,80 @@
fun interface KRunnable {
abstract fun run()
}
fun <T : Any?> id(x: T): T {
return x
}
fun run1(r: KRunnable) {
}
fun run2(r1: KRunnable, r2: KRunnable) {
}
fun <T> test0(a: T) where T : KRunnable, T : Function0<Unit> {
run1(r = a)
}
fun test1(a: Function0<Unit>) {
when {
a is KRunnable -> { //BLOCK
run1(r = a /*as KRunnable */)
}
}
}
fun test2(a: KRunnable) {
a as Function0<Unit> /*~> Unit */
run1(r = a)
}
fun test3(a: Function0<Unit>) {
when {
a is KRunnable -> { //BLOCK
run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */)
}
}
}
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
when {
a is KRunnable -> { //BLOCK
run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */)
}
}
}
fun test5(a: Any) {
when {
a is KRunnable -> { //BLOCK
run1(r = a /*as KRunnable */)
}
}
}
fun test5x(a: Any) {
when {
a is KRunnable -> { //BLOCK
a as Function0<Unit> /*~> Unit */
run1(r = a /*as KRunnable */)
}
}
}
fun test6(a: Any) {
a as Function0<Unit> /*~> Unit */
run1(r = a /*as Function0<Unit> */ /*-> KRunnable */)
}
fun test8(a: Function0<Unit>) {
run1(r = id<Function0<Unit>>(x = a) /*-> KRunnable */)
}
fun test9() {
run1(r = ::test9 /*-> KRunnable */)
}