Add test for Obsolete issues
#KT-15956 Obsolete #KT-15751 Obsolete #KT-16417 Obsolete #KT-21787 Obsolete
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
// FILE: 1.kt
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
class A {
|
||||
val foo = fun(call: () -> Unit) =
|
||||
ext {
|
||||
fun send() {
|
||||
call()
|
||||
}
|
||||
|
||||
bar {
|
||||
send()
|
||||
}
|
||||
}
|
||||
|
||||
fun bar(body: () -> Unit) {
|
||||
body()
|
||||
}
|
||||
|
||||
inline fun A.ext(init: X.() -> Unit) {
|
||||
return X().init()
|
||||
}
|
||||
|
||||
class X
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
A().foo { result = "OK" }
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// FILE: 1.kt
|
||||
// IGNORE_BACKEND: JS
|
||||
// WITH_RUNTIME
|
||||
public inline fun <T> T.myalso(block: (T) -> Unit): T {
|
||||
block(this)
|
||||
return this
|
||||
}
|
||||
|
||||
public inline fun <T, R : Any> Iterable<T>.mymapNotNull(transform: (T) -> R?): List<R> {
|
||||
return mapNotNullTo(ArrayList<R>(), transform)
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
var result = -1;
|
||||
|
||||
fun box(): String {
|
||||
fff()
|
||||
return if (result == 1) "OK" else "fail $result"
|
||||
}
|
||||
|
||||
fun fff(): Int {
|
||||
val y = 0
|
||||
return 0.myalso {
|
||||
fun increase(x: Int): Int = x + y
|
||||
|
||||
val values = listOf(1).mymapNotNull { something(::increase, it) }
|
||||
result = values[0]!!
|
||||
}
|
||||
}
|
||||
|
||||
fun something(increase: (Int) -> Int, x: Int): Int? {
|
||||
return increase(x)
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
// FILE: 1.kt
|
||||
class A {
|
||||
var field = 0
|
||||
|
||||
inline fun a(f: () -> Any): Any {
|
||||
try {
|
||||
val value = f()
|
||||
return value
|
||||
} finally {
|
||||
field--
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun b(rule: () -> Unit) {
|
||||
try {
|
||||
rule()
|
||||
} catch (fail: Throwable) {}
|
||||
}
|
||||
|
||||
fun c(vararg functions: () -> Any): Any = a {
|
||||
for (function in functions) {
|
||||
b { return function() }
|
||||
}
|
||||
throw RuntimeException()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
a.c ({ "OK" })
|
||||
if (a.field != -1) return "fail 1: ${a.field}"
|
||||
|
||||
try {
|
||||
a.c({ null!! })
|
||||
} catch (e: RuntimeException) {
|
||||
// OK
|
||||
} catch (e: Throwable) {
|
||||
return "fail 2: $e"
|
||||
}
|
||||
|
||||
return a.c ({ "OK" }) as String
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: 1.kt
|
||||
// WITH_REFLECT
|
||||
// IGNORE_BACKEND: JVM_IR
|
||||
|
||||
package foo
|
||||
|
||||
import kotlin.reflect.full.primaryConstructor
|
||||
|
||||
inline fun <reified T : Any> f(): String {
|
||||
var result = ""
|
||||
for (p in T::class.primaryConstructor!!.parameters.sortedBy { it.index }) {
|
||||
result += p.name
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
import foo.*
|
||||
|
||||
class A(val O: Int, val K: Int)
|
||||
|
||||
fun box(): String {
|
||||
return f<A>()
|
||||
}
|
||||
Reference in New Issue
Block a user