[IR] dumpKotlinLike: add testdata for FIR tests
This commit is contained in:
committed by
teamcityserver
parent
d7bd4240e1
commit
c68040753d
@@ -0,0 +1,66 @@
|
||||
fun interface Fn<T : Any?, R : Any?> {
|
||||
abstract fun run(s: String, i: Int, t: T): R
|
||||
|
||||
}
|
||||
|
||||
class J {
|
||||
constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
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> {
|
||||
private constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
override fun run(s: String, i: Int, t: String): Int {
|
||||
return 1
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<no name provided>()
|
||||
}
|
||||
get
|
||||
|
||||
val fis: Fn<Int, String>
|
||||
field = { // BLOCK
|
||||
local class <no name provided> : Fn<Int, String> {
|
||||
private constructor() /* primary */ {
|
||||
super/*Any*/()
|
||||
/* <init>() */
|
||||
|
||||
}
|
||||
|
||||
override fun run(s: String, i: Int, t: Int): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
<no name provided>()
|
||||
}
|
||||
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 */
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
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])
|
||||
}
|
||||
/*-> IFoo */])
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
fun interface MyRunnable {
|
||||
abstract fun run()
|
||||
|
||||
}
|
||||
|
||||
fun test(a: Any, r: MyRunnable) {
|
||||
when {
|
||||
a is MyRunnable -> foo(rs = [local fun <anonymous>() {
|
||||
return Unit
|
||||
}
|
||||
/*-> MyRunnable */, r, a /*as MyRunnable */])
|
||||
}
|
||||
}
|
||||
|
||||
fun foo(vararg rs: MyRunnable) {
|
||||
}
|
||||
Vendored
+36
@@ -0,0 +1,36 @@
|
||||
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()
|
||||
}
|
||||
/*-> KRunnable */
|
||||
}
|
||||
|
||||
fun testSamConversion() {
|
||||
use(r = ::foo0 /*-> KRunnable */)
|
||||
}
|
||||
|
||||
fun testSamConversionOnAdapted() {
|
||||
use(r = local fun foo1() {
|
||||
foo1()
|
||||
}
|
||||
/*-> KRunnable */)
|
||||
}
|
||||
Vendored
+69
@@ -0,0 +1,69 @@
|
||||
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 -> run1(r = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(a: KRunnable) {
|
||||
a as Function0<Unit> /*~> Unit */
|
||||
run1(r = a /*as Function0<Unit> */)
|
||||
}
|
||||
|
||||
fun test3(a: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(a: Function0<Unit>, b: Function0<Unit>) {
|
||||
when {
|
||||
a is KRunnable -> run2(r1 = a /*as KRunnable */, r2 = b /*-> KRunnable */)
|
||||
}
|
||||
}
|
||||
|
||||
fun test5(a: Any) {
|
||||
when {
|
||||
a is KRunnable -> run1(r = a /*as KRunnable */)
|
||||
}
|
||||
}
|
||||
|
||||
fun test5x(a: Any) {
|
||||
when {
|
||||
a is KRunnable -> { // BLOCK
|
||||
a /*as KRunnable */ 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 */)
|
||||
}
|
||||
Reference in New Issue
Block a user