tests: Update external tests (1.1.2-dev-393)
This commit is contained in:
Vendored
+45
@@ -0,0 +1,45 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
abstract class A<R> {
|
||||
abstract fun getO() : R
|
||||
|
||||
abstract fun getK() : R
|
||||
}
|
||||
|
||||
|
||||
inline fun <R> doWork(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box() : String {
|
||||
val o = "O"
|
||||
val p = "GOOD"
|
||||
val result = doWork {
|
||||
val k = "K"
|
||||
val s = object : A<String>() {
|
||||
|
||||
val param = p;
|
||||
|
||||
override fun getO(): String {
|
||||
return o;
|
||||
}
|
||||
|
||||
override fun getK(): String {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
|
||||
s.getO() + s.getK() + s.param
|
||||
}
|
||||
|
||||
if (result != "OKGOOD") return "fail $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
abstract class A<R>(val param: R) {
|
||||
abstract fun getO() : R
|
||||
|
||||
abstract fun getK() : R
|
||||
}
|
||||
|
||||
|
||||
inline fun <R> doWork(job: ()-> R) : R {
|
||||
return job()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box() : String {
|
||||
val o = "O"
|
||||
val result = doWork {
|
||||
val k = "K"
|
||||
val s = object : A<String>("11") {
|
||||
override fun getO(): String {
|
||||
return o;
|
||||
}
|
||||
|
||||
override fun getK(): String {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
|
||||
s.getO() + s.getK() + s.param
|
||||
}
|
||||
|
||||
if (result != "OK11") return "fail $result"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
Vendored
+85
@@ -0,0 +1,85 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
|
||||
abstract class A<R> {
|
||||
abstract fun getO() : R
|
||||
|
||||
abstract fun getK() : R
|
||||
|
||||
abstract fun getParam() : R
|
||||
}
|
||||
|
||||
inline fun <R> doWork(crossinline jobO: ()-> R, crossinline jobK: ()-> R, param: R) : A<R> {
|
||||
val s = object : A<R>() {
|
||||
|
||||
override fun getO(): R {
|
||||
return jobO()
|
||||
}
|
||||
override fun getK(): R {
|
||||
return jobK()
|
||||
}
|
||||
|
||||
override fun getParam(): R {
|
||||
return param
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
inline fun <R> doWorkInConstructor(crossinline jobO: ()-> R, crossinline jobK: ()-> R, param: R) : A<R> {
|
||||
val s = object : A<R>() {
|
||||
|
||||
val p = param;
|
||||
|
||||
val o1 = jobO()
|
||||
|
||||
val k1 = jobK()
|
||||
|
||||
override fun getO(): R {
|
||||
return o1
|
||||
}
|
||||
override fun getK(): R {
|
||||
return k1
|
||||
}
|
||||
|
||||
override fun getParam(): R {
|
||||
return p
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun test1(): String {
|
||||
val o = "O"
|
||||
|
||||
val result = doWork ({o}, {"K"}, "GOOD")
|
||||
|
||||
return result.getO() + result.getK() + result.getParam()
|
||||
}
|
||||
|
||||
fun test2() : String {
|
||||
//same names as in object
|
||||
val o1 = "O"
|
||||
val k1 = "K"
|
||||
|
||||
val result = doWorkInConstructor ({o1}, {k1}, "GOOD")
|
||||
|
||||
return result.getO() + result.getK() + result.getParam()
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val result1 = test1();
|
||||
if (result1 != "OKGOOD") return "fail1 $result1"
|
||||
|
||||
val result2 = test2();
|
||||
if (result2 != "OKGOOD") return "fail2 $result2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
|
||||
abstract class A<R>(val param : R) {
|
||||
abstract fun getO() : R
|
||||
|
||||
abstract fun getK() : R
|
||||
}
|
||||
|
||||
inline fun <R> doWork(crossinline jobO: ()-> R, crossinline jobK: ()-> R, param: R) : A<R> {
|
||||
val s = object : A<R>(param) {
|
||||
|
||||
override fun getO(): R {
|
||||
return jobO()
|
||||
}
|
||||
override fun getK(): R {
|
||||
return jobK()
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
inline fun <R> doWorkInConstructor(crossinline jobO: ()-> R, crossinline jobK: ()-> R, crossinline param: () -> R) : A<R> {
|
||||
val s = object : A<R>(param()) {
|
||||
val o1 = jobO()
|
||||
|
||||
val k1 = jobK()
|
||||
|
||||
override fun getO(): R {
|
||||
return o1
|
||||
}
|
||||
override fun getK(): R {
|
||||
return k1
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun test1(): String {
|
||||
val o = "O"
|
||||
|
||||
val result = doWork ({o}, {"K"}, "11")
|
||||
|
||||
return result.getO() + result.getK() + result.param
|
||||
}
|
||||
|
||||
fun test2() : String {
|
||||
//same names as in object
|
||||
val o1 = "O"
|
||||
val k1 = "K"
|
||||
val param = "11"
|
||||
val result = doWorkInConstructor ({o1}, {k1}, {param})
|
||||
|
||||
return result.getO() + result.getK() + result.param
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
val result1 = test1();
|
||||
if (result1 != "OK11") return "fail1 $result1"
|
||||
|
||||
val result2 = test2();
|
||||
if (result2 != "OK11") return "fail2 $result2"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun bar(crossinline y: () -> String) = {
|
||||
call(y)
|
||||
}
|
||||
|
||||
public inline fun <T> call(f: () -> T): T = f()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return bar {"OK"} ()
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun bar(crossinline y: () -> String) = {
|
||||
{ { call(y) }() }()
|
||||
}
|
||||
|
||||
public inline fun <T> call(f: () -> T): T = f()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return bar {"OK"} ()
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun bar(crossinline y: () -> String) = {
|
||||
{ { call(y) }() }()
|
||||
}
|
||||
|
||||
public inline fun <T> call(crossinline f: () -> T): T = {{ f() }()}()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val bar1 = bar {"123"} ()
|
||||
val bar2 = bar2 { "1234" } ()
|
||||
return if (bar1 == "123" && bar2 == "1234") "OK" else "fail: $bar1 $bar2"
|
||||
}
|
||||
|
||||
inline fun bar2(crossinline y: () -> String) = {
|
||||
{ { call(y) }() }()
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
internal interface A<T> {
|
||||
fun run(): T;
|
||||
}
|
||||
|
||||
internal inline fun bar(crossinline y: () -> String) = object : A<String> {
|
||||
override fun run() : String {
|
||||
return call(y)
|
||||
}
|
||||
}
|
||||
|
||||
public inline fun <T> call(crossinline f: () -> T): T = object : A<T> {
|
||||
override fun run() : T {
|
||||
return f()
|
||||
}
|
||||
}.run()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return bar { "OK" }.run()
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
open class Entity(val value: String)
|
||||
|
||||
public abstract class Task<T>() {
|
||||
abstract fun calc(): T
|
||||
}
|
||||
|
||||
fun <Self : Entity> nullableTask(factory: () -> Task<Self>): Task<Self> {
|
||||
return factory()
|
||||
}
|
||||
|
||||
inline fun<reified Self : Entity> Self.directed(): Task<Self> =
|
||||
nullableTask {
|
||||
object : Task<Self>() {
|
||||
override fun calc(): Self = this@directed
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
//KT-7490
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return Entity("OK").directed().calc().value
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface Run {
|
||||
fun run(): String
|
||||
}
|
||||
|
||||
internal class A {
|
||||
inline fun doSomething(): Run {
|
||||
return object : Run {
|
||||
override fun run(): String = "OK"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().doSomething().run()
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
internal class A {
|
||||
inline fun doSomething(): String {
|
||||
return {
|
||||
"OK"
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().doSomething()
|
||||
}
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
internal class A {
|
||||
inline fun doSomething(s: String): String {
|
||||
return {
|
||||
s
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().doSomething("OK")
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface Run {
|
||||
fun run(): String
|
||||
}
|
||||
|
||||
inline fun i2(crossinline s: () -> String): Run {
|
||||
return i1 {
|
||||
object : Run {
|
||||
override fun run(): String {
|
||||
return s()
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun i1(crossinline s: () -> String): Run {
|
||||
return object : Run {
|
||||
override fun run(): String {
|
||||
return s()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
inline fun i4(crossinline s: () -> String): Run {
|
||||
return i3 {
|
||||
object : Run {
|
||||
override fun run(): String {
|
||||
return s()
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun i3(crossinline s: () -> String): Run {
|
||||
return i2 {
|
||||
object : Run {
|
||||
override fun run(): String {
|
||||
return s()
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val i4 = i4 { "OK" }
|
||||
return i4.run()
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
enum class X {
|
||||
A,
|
||||
B
|
||||
}
|
||||
|
||||
inline fun test(x: X, s: (X) -> String): String {
|
||||
return s(x)
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(X.A) {
|
||||
when(it) {
|
||||
X.A-> "O"
|
||||
X.B-> "K"
|
||||
}
|
||||
} + test(X.B) {
|
||||
when(it) {
|
||||
X.A-> "O"
|
||||
X.B-> "K"
|
||||
}
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
enum class X {
|
||||
A,
|
||||
B
|
||||
}
|
||||
|
||||
inline fun test(e: X): String {
|
||||
return when(e) {
|
||||
X.A-> "O"
|
||||
X.B-> "K"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(X.A) + test(X.B)
|
||||
}
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
enum class X {
|
||||
A,
|
||||
B
|
||||
}
|
||||
|
||||
enum class Y {
|
||||
A,
|
||||
B
|
||||
}
|
||||
|
||||
inline fun test(e: X): String {
|
||||
return when(e) {
|
||||
X.A-> "O"
|
||||
X.B-> "K"
|
||||
}
|
||||
}
|
||||
|
||||
fun funForAdditionalMappingArrayInMappingFile(e: Y): String {
|
||||
return when(e) {
|
||||
Y.A-> "O"
|
||||
Y.B-> "K"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(X.A) + test(X.B)
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
enum class X {
|
||||
A,
|
||||
B
|
||||
}
|
||||
|
||||
enum class Y {
|
||||
A,
|
||||
B
|
||||
}
|
||||
|
||||
fun funForAdditionalMappingArrayInMappingFile(e: Y): String {
|
||||
return when(e) {
|
||||
Y.A-> "O"
|
||||
Y.B-> "K"
|
||||
}
|
||||
}
|
||||
|
||||
inline fun test(e: X): String {
|
||||
return when(e) {
|
||||
X.A-> "O"
|
||||
X.B-> "K"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return test(X.A) + test(X.B)
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// WITH_REFLECT
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun inf(crossinline cif: Any.() -> String): () -> String {
|
||||
return {
|
||||
object : () -> String {
|
||||
override fun invoke() = cif()
|
||||
}
|
||||
}()
|
||||
}
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val simpleName = inf {
|
||||
javaClass.simpleName
|
||||
}()
|
||||
|
||||
if (simpleName != "" ) return "fail 1: $simpleName"
|
||||
|
||||
val name = inf {
|
||||
javaClass.name
|
||||
}()
|
||||
|
||||
if (name != "_2Kt\$box$\$inlined\$inf$2$1" ) return "fail 2: $name"
|
||||
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun test(cond: Boolean, crossinline cif: () -> String): String {
|
||||
return if (cond) {
|
||||
{ cif() }()
|
||||
}
|
||||
else {
|
||||
cif()
|
||||
}
|
||||
}
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val s = "OK"
|
||||
return test(true) {
|
||||
{
|
||||
s
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface IZ {
|
||||
fun z()
|
||||
}
|
||||
|
||||
interface IZZ : IZ {
|
||||
fun zz()
|
||||
}
|
||||
|
||||
inline fun implZZ(zImpl: IZ, crossinline zzImpl: () -> Unit): IZZ =
|
||||
object : IZZ, IZ by zImpl {
|
||||
override fun zz() = zzImpl()
|
||||
}
|
||||
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
var result = "fail";
|
||||
|
||||
object ZImpl : IZ {
|
||||
override fun z() {
|
||||
result = "O"
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val zz = implZZ(ZImpl) { result += "K" }
|
||||
zz.z()
|
||||
zz.zz()
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline fun inline1(crossinline action: () -> Unit) {
|
||||
action();
|
||||
{ action() }()
|
||||
}
|
||||
|
||||
inline fun inline2(crossinline action: () -> Unit) = { action() }
|
||||
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
var result = "fail"
|
||||
fun box(): String {
|
||||
inline1 { inline2 { result = "OK" }() }
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline fun inline1(crossinline action: () -> Unit) {
|
||||
{ action () }
|
||||
action();
|
||||
}
|
||||
|
||||
inline fun inline2(crossinline action: () -> Unit) = { action() }
|
||||
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
var result = "fail"
|
||||
fun box(): String {
|
||||
inline1 { inline2 { result ="OK" }() }
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline fun inline1(crossinline action: () -> Unit) {
|
||||
{ action () }
|
||||
action();
|
||||
}
|
||||
|
||||
inline fun inline2(crossinline action: () -> Unit) = {
|
||||
action()
|
||||
}
|
||||
|
||||
|
||||
// FILE: 2.kt
|
||||
import test.*
|
||||
|
||||
var result = "fail"
|
||||
fun box(): String {
|
||||
inline1 {
|
||||
inline2 { { result ="OK" }() }()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
//WITH_RUNTIME
|
||||
//FULL_JDK
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline fun crashMe(crossinline callback: () -> Unit): Function0<Unit> {
|
||||
return object: Function0<Unit> {
|
||||
override fun invoke() {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
import java.lang.reflect.Modifier
|
||||
|
||||
var result = "fail"
|
||||
|
||||
|
||||
fun box(): String {
|
||||
val crashMe = crashMe { result = "OK" }
|
||||
val modifiers = crashMe::class.java.getDeclaredConstructor().modifiers
|
||||
if (!Modifier.isPublic(modifiers)) return "fail $modifiers"
|
||||
|
||||
crashMe.invoke()
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
public enum class X { A, B }
|
||||
|
||||
public inline fun switch(x: X): String = when (x) {
|
||||
X.A -> "O"
|
||||
X.B -> "K"
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return switch(X.A) + switch(X.B)
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
public inline fun <T, R> T.myLet(f: (T) -> R): R = f(this)
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
interface foo {
|
||||
fun bar(): String
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val baz = "OK".myLet {
|
||||
object : foo {
|
||||
override fun bar() = it
|
||||
}
|
||||
}
|
||||
return baz.bar()
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class Test(val _member: String) {
|
||||
val _parameter: Z = test {
|
||||
object : Z {
|
||||
override val property = _member
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Z {
|
||||
val property: String
|
||||
}
|
||||
|
||||
inline fun test(s: () -> Z): Z {
|
||||
return s()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val test = Test("OK")
|
||||
|
||||
return test._parameter.property
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class Test(val _member: String) {
|
||||
val _parameter: Z<Z<String>> = test {
|
||||
object : Z<Z<String>> {
|
||||
override val property = test {
|
||||
object : Z<String> {
|
||||
override val property = _member
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Z<T> {
|
||||
val property: T
|
||||
}
|
||||
|
||||
inline fun <T> test(s: () -> Z<T>): Z<T> {
|
||||
return s()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
|
||||
val test = Test("OK")
|
||||
|
||||
return test._parameter.property.property
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
|
||||
|
||||
inline fun inlineFun(p: () -> Unit) {
|
||||
p()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
public fun box(): String {
|
||||
var z = "fail"
|
||||
inlineFun {
|
||||
val obj = object {
|
||||
val _delegate by lazy {
|
||||
z = "OK"
|
||||
}
|
||||
}
|
||||
|
||||
obj._delegate
|
||||
}
|
||||
|
||||
return z;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// WITH_RUNTIME
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
fun <T> T.noInline(p: (T) -> Unit) {
|
||||
p(this)
|
||||
}
|
||||
|
||||
inline fun inlineCall(p: () -> Unit) {
|
||||
p()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val loci = listOf("a", "b", "c")
|
||||
var gene = "g1"
|
||||
|
||||
inlineCall {
|
||||
val value = 10.0
|
||||
loci.forEach {
|
||||
var locusMap = 1.0
|
||||
{
|
||||
locusMap = value
|
||||
gene = "OK"
|
||||
}()
|
||||
}
|
||||
}
|
||||
return gene
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun inlineCall(p: () -> Unit) {
|
||||
p()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var gene = "g1"
|
||||
|
||||
inlineCall {
|
||||
val value = 10.0
|
||||
inlineCall {
|
||||
{
|
||||
value
|
||||
gene = "OK"
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
return gene
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
public inline fun myRun(block: () -> Unit) {
|
||||
return block()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var res = ""
|
||||
myRun {
|
||||
val x = object {
|
||||
fun foo() {
|
||||
res = "OK"
|
||||
}
|
||||
}
|
||||
object {
|
||||
fun bar() = x.foo()
|
||||
}.bar()
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
inline fun testNested(crossinline f: (String) -> Unit) {
|
||||
object : A {
|
||||
override fun run() {
|
||||
f("OK")
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
|
||||
inline fun test(crossinline f: (String) -> Unit) {
|
||||
testNested { it -> { f(it) }()}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
// NO_CHECK_LAMBDA_INLINING
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <T> inlineFun(arg: T, f: (T) -> Unit) {
|
||||
f(arg)
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
inlineFun("1") { c ->
|
||||
{
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
{
|
||||
result = param + c + a
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return if (result == "start12") "OK" else "fail: $result"
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
|
||||
{
|
||||
f(arg)
|
||||
}()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
result = param + a
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
return if (result == "start2") "OK" else "fail: $result"
|
||||
}
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
|
||||
{
|
||||
f(arg)
|
||||
}()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
inlineFun("1") { c ->
|
||||
{
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
{
|
||||
result = param + c + a
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return if (result == "start12") "OK" else "fail: $result"
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
|
||||
{
|
||||
f(arg)
|
||||
}()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
inlineFun("1") { c ->
|
||||
{
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
result = param + c + a
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return if (result == "start12") "OK" else "fail: $result"
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
inline fun testNested(crossinline f: (String) -> Unit) {
|
||||
object : A {
|
||||
override fun run() {
|
||||
f("OK")
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
|
||||
fun test(f: (String) -> Unit) {
|
||||
testNested { it -> { f(it) }()}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
class B(val o: String, val k: String) {
|
||||
|
||||
inline fun testNested(crossinline f: (String) -> Unit) {
|
||||
object : A {
|
||||
override fun run() {
|
||||
f(o)
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
|
||||
inline fun test(crossinline f: (String) -> Unit) {
|
||||
testNested { it -> { f(it + k) }() }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
B("O", "K").test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
var addParam = "_additional_"
|
||||
|
||||
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
|
||||
{
|
||||
f(arg + addParam)
|
||||
}()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
{
|
||||
inlineFun("1") { c ->
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
{
|
||||
result = param + c + a
|
||||
}()
|
||||
}()
|
||||
}
|
||||
|
||||
}
|
||||
}()
|
||||
|
||||
return if (result == "start1_additional_2_additional_") "OK" else "fail: $result"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
var addParam = "_additional_"
|
||||
|
||||
inline fun inlineFun(arg: String, f: (String) -> Unit) {
|
||||
f(arg + addParam)
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
inlineFun("1") { c ->
|
||||
{
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
{
|
||||
result = param + c + a
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return if (result == "start1_additional_2_additional_") "OK" else "fail: $result"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
var addParam = "_additional_"
|
||||
|
||||
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
|
||||
{
|
||||
f(arg + addParam)
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
result = param + a
|
||||
}()
|
||||
}
|
||||
return if (result == "start2_additional_") "OK" else "fail: $result"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
var addParam = "_additional_"
|
||||
|
||||
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
|
||||
{
|
||||
f(arg + addParam)
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
{
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
result = param + a
|
||||
}()
|
||||
}
|
||||
}()
|
||||
return if (result == "start2_additional_") "OK" else "fail: $result"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
var addParam = "_additional_"
|
||||
|
||||
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
|
||||
{
|
||||
f(arg + addParam)
|
||||
}()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
inlineFun("1") { c ->
|
||||
{
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
{
|
||||
result = param + c + a
|
||||
}()
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return if (result == "start1_additional_2_additional_") "OK" else "fail: $result"
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {
|
||||
val param = "start"
|
||||
var result = "fail"
|
||||
var addParam = "_additional_"
|
||||
|
||||
inline fun inlineFun(arg: String, crossinline f: (String) -> Unit) {
|
||||
{
|
||||
f(arg + addParam)
|
||||
}()
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
inlineFun("1") { c ->
|
||||
{
|
||||
inlineFun("2") { a ->
|
||||
{
|
||||
result = param + c + a
|
||||
}()
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
return if (result == "start1_additional_2_additional_") "OK" else "fail: $result"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
class B(val o: String, val k: String) {
|
||||
|
||||
inline fun testNested(crossinline f: (String) -> Unit) {
|
||||
object : A {
|
||||
override fun run() {
|
||||
f(o)
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
|
||||
inline fun test(crossinline f: (String) -> Unit) {
|
||||
testNested { it -> { f(it + "K") }() }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
B("O", "fail").test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
class B(val o: String, val k: String) {
|
||||
|
||||
inline fun testNested(crossinline f: (String) -> Unit) {
|
||||
object : A {
|
||||
override fun run() {
|
||||
f(o)
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
|
||||
fun test(f: (String) -> Unit) {
|
||||
testNested { it -> { f(it + k) }() }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
B("O", "K").test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
class B(val o: String, val k: String) {
|
||||
|
||||
inline fun testNested(crossinline f2: (String) -> Unit, crossinline f3: (String) -> Unit) {
|
||||
object : A {
|
||||
override fun run() {
|
||||
f2(o)
|
||||
f3(k)
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
|
||||
inline fun test(crossinline f: (String) -> Unit) {
|
||||
testNested ({ it -> f(it + o) }) { it -> f(it + k) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
B("O", "K").test { it -> result += it }
|
||||
return if (result == "OOKK") "OK" else "fail: $result"
|
||||
}
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
class B(val o: String, val k: String) {
|
||||
|
||||
inline fun testNested(crossinline f: (String) -> Unit, crossinline f2: (String) -> Unit) {
|
||||
object : A {
|
||||
override fun run() {
|
||||
f(o)
|
||||
f2(k)
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
|
||||
inline fun test(crossinline f: (String) -> Unit) {
|
||||
call {
|
||||
{
|
||||
testNested ({ it -> { f(it + o) }() }) { it -> { f(it + k) }() }
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun call(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
B("O", "K").test { it -> result += it }
|
||||
return if (result == "OOKK") "OK" else "fail: $result"
|
||||
}
|
||||
+44
@@ -0,0 +1,44 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
interface A {
|
||||
fun run()
|
||||
}
|
||||
|
||||
class B(val o: String, val k: String) {
|
||||
|
||||
inline fun testNested(crossinline f: (String) -> Unit, crossinline f2: (String) -> Unit) {
|
||||
object : A {
|
||||
override fun run() {
|
||||
f(o)
|
||||
f2(k)
|
||||
}
|
||||
}.run()
|
||||
}
|
||||
|
||||
inline fun test(crossinline f: (String) -> Unit) {
|
||||
call {
|
||||
f("start");
|
||||
{
|
||||
testNested ({ it -> { f(it + o) }() }) { it -> { f(it + k) }() }
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
inline fun call(f: () -> Unit) {
|
||||
f()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
B("O", "K").test { it -> result += it }
|
||||
return if (result == "startOOKK") "OK" else "fail: $result"
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class W(val value: Any)
|
||||
|
||||
inline fun W.safe(crossinline body : Any.() -> Unit) {
|
||||
{
|
||||
this.value?.body()
|
||||
}()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
W("OK").safe {
|
||||
result = this as String
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class W(val value: Any)
|
||||
|
||||
inline fun W.safe(crossinline body : Any.() -> Unit) {
|
||||
{
|
||||
this.value?.body()
|
||||
}()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
W("OK").safe {
|
||||
{
|
||||
result = this as String
|
||||
}()
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
// IGNORE_BACKEND: NATIVE
|
||||
// FILE: 1.kt
|
||||
package test
|
||||
|
||||
inline fun <reified T> makeRunnable(noinline lambda: ()->Unit) : Runnable {
|
||||
return Runnable(lambda)
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
|
||||
makeRunnable<String> { result = "OK" }.run()
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class A {
|
||||
|
||||
fun callK(): String {
|
||||
return "K"
|
||||
}
|
||||
|
||||
fun callO(): String {
|
||||
return "O"
|
||||
}
|
||||
|
||||
fun testCall(): String = test { callO() }
|
||||
|
||||
inline fun test(crossinline l: () -> String): String {
|
||||
return {
|
||||
l() + callK()
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().testCall()
|
||||
}
|
||||
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class Person(val name: String) {
|
||||
|
||||
fun sayName() = doSayName { name }
|
||||
|
||||
inline fun doSayName(crossinline call: () -> String): String {
|
||||
return nestedSayName1 { nestedSayName2 { call() } }
|
||||
}
|
||||
|
||||
fun nestedSayName1(call: () -> String) = call()
|
||||
|
||||
inline fun nestedSayName2(call: () -> String) = call()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return Person("OK").sayName()
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class Person(val name: String) {
|
||||
|
||||
fun sayName() = doSayName { name }
|
||||
|
||||
inline fun doSayName(crossinline call: () -> String): String {
|
||||
return nestedSayName1 { name + Person("sub").nestedSayName2 { call() } }
|
||||
}
|
||||
|
||||
fun nestedSayName1(call: () -> String) = call()
|
||||
|
||||
inline fun nestedSayName2(call: () -> String) = name + call()
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val res = Person("OK").sayName()
|
||||
if (res != "OKsubOK") return "fail: $res"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
class Company(val name: String) {
|
||||
fun sayName() = Person("test").doSayName { name }
|
||||
}
|
||||
|
||||
class Person(val name: String) {
|
||||
|
||||
inline fun doSayName(crossinline call: () -> String): String {
|
||||
return companyName { parsonName { call() } }
|
||||
}
|
||||
|
||||
inline fun parsonName(call: () -> String) = call()
|
||||
|
||||
fun companyName(call: () -> String) = call()
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return Company("OK").sayName()
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
// FILE: 1.kt
|
||||
|
||||
package test
|
||||
|
||||
fun Person.sayName() = doSayName { name }
|
||||
|
||||
class Person(val name: String)
|
||||
|
||||
inline fun Person.doSayName(crossinline call: () -> String): String {
|
||||
return companyName { parsonName { call() } }
|
||||
}
|
||||
|
||||
inline fun Person.parsonName(call: () -> String) = call()
|
||||
|
||||
fun Person.companyName(call: () -> String) = call()
|
||||
|
||||
// FILE: 2.kt
|
||||
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return Person("OK").sayName()
|
||||
}
|
||||
Reference in New Issue
Block a user