[JS IR] Test in-line anonymous functions with extension functions
This commit is contained in:
+14
-4
@@ -8,12 +8,12 @@ fun <T, R> myWith(t: T, f: (T) -> R) = f(t)
|
||||
// HAS_NO_CAPTURED_VARS: function=noCapture except=myWith;noCapture$lambda
|
||||
fun noCapture() = myWith(42) { it }
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: captureLocalVariableReadOnly except=myWith IGNORED_BACKENDS=JS
|
||||
// HAS_NO_CAPTURED_VARS: function=captureLocalVariableReadOnly except=myWith IGNORED_BACKENDS=JS
|
||||
// CHECK_CONTAINS_NO_CALLS: captureLocalVariableReadOnly except=myWith
|
||||
// HAS_NO_CAPTURED_VARS: function=captureLocalVariableReadOnly except=myWith
|
||||
fun captureLocalVariableReadOnly(a: Int) = myWith(1) { a + it }
|
||||
|
||||
// CHECK_CONTAINS_NO_CALLS: captureLocalVariableReadWrite except=myWith IGNORED_BACKENDS=JS
|
||||
// HAS_NO_CAPTURED_VARS: function=captureLocalVariableReadWrite except=myWith IGNORED_BACKENDS=JS
|
||||
// CHECK_CONTAINS_NO_CALLS: captureLocalVariableReadWrite except=myWith
|
||||
// HAS_NO_CAPTURED_VARS: function=captureLocalVariableReadWrite except=myWith
|
||||
fun captureLocalVariableReadWrite(): Int {
|
||||
var a = 41
|
||||
return myWith(1) {
|
||||
@@ -44,6 +44,14 @@ class A(val i: Int) {
|
||||
}
|
||||
}
|
||||
|
||||
fun A.captureClassFieldInExtension() = myWith(300) { it + i }
|
||||
|
||||
class D(val l: Int) {
|
||||
fun A.captureClassFieldInMemberExtension() = myWith(400) { it + i + l }
|
||||
|
||||
fun captureClassFieldInMemberExtension(a: A) = a.captureClassFieldInMemberExtension()
|
||||
}
|
||||
|
||||
fun unusedLambda(f: () -> Unit) {
|
||||
{ f() }
|
||||
}
|
||||
@@ -55,6 +63,8 @@ fun box(): String {
|
||||
if (captureGlobalVariable() != 26) return "fail captureGlobalVariable()"
|
||||
if (A(23).captureClassField() != 123) return "fail A(23).captureClassField()"
|
||||
if (A(300).B(400).C(500).captureInnerClassField() != 1400) return "A(300).B(400).C(500).captureInnerClassField()"
|
||||
if (A(12).captureClassFieldInExtension() != 312) return "A(12).captureClassFieldInExtension()"
|
||||
if (D(37).captureClassFieldInMemberExtension(A(100)) != 537) return "D(37).captureClassFieldInMemberExtension(A(100))"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user