Skip inline lambdas in 'InlineCallSite' parameter calculation; Fix for KT-10679: Wrong outer after inline

#KT-10679 Fixed
This commit is contained in:
Michael Bogdanov
2016-01-15 15:13:47 +03:00
parent abf4a5cf43
commit 7eec1d8e1d
9 changed files with 130 additions and 6 deletions
@@ -0,0 +1,15 @@
import test.*
fun box(): String {
val res = call {
{ "OK" }
}
var enclosingMethod = res.javaClass.enclosingMethod
if (enclosingMethod?.name != "box") return "fail 1: ${enclosingMethod?.name}"
var enclosingClass = res.javaClass.enclosingClass
if (enclosingClass?.name != "AnonymousInLambda_1Kt") return "fail 2: ${enclosingClass?.name}"
return res()
}
@@ -0,0 +1,3 @@
package test
inline fun <R> call(s: () -> R) = s()
@@ -0,0 +1,27 @@
import test.*
fun box(): String {
val res = call {
test { "OK" }
}
var enclosingMethod = res.javaClass.enclosingMethod
if (enclosingMethod?.name != "box") return "fail 1: ${enclosingMethod?.name}"
var enclosingClass = res.javaClass.enclosingClass
if (enclosingClass?.name != "InlineChain_1Kt") return "fail 2: ${enclosingClass?.name}"
val res2 = call {
call {
test { "OK" }
}
}
enclosingMethod = res2.javaClass.enclosingMethod
if (enclosingMethod?.name != "box") return "fail 1: ${enclosingMethod?.name}"
enclosingClass = res2.javaClass.enclosingClass
if (enclosingClass?.name != "InlineChain_1Kt") return "fail 2: ${enclosingClass?.name}"
return res2()
}
@@ -0,0 +1,5 @@
package test
inline fun <R> call(s: () -> R) = s()
inline fun test(crossinline z: () -> String) = { z() }
@@ -0,0 +1,27 @@
import test.*
fun box(): String {
val res = call {
test { "OK" }
}
var enclosingMethod = res.javaClass.enclosingMethod
if (enclosingMethod?.name != "invoke") return "fail 1: ${enclosingMethod?.name}"
var enclosingClass = res.javaClass.enclosingClass
if (enclosingClass?.name != "InlineChain2_1Kt\$box$\$inlined\$call$1") return "fail 2: ${enclosingClass?.name}"
val res2 = call {
call {
test { "OK" }
}
}
enclosingMethod = res2.javaClass.enclosingMethod
if (enclosingMethod?.name != "invoke") return "fail 1: ${enclosingMethod?.name}"
enclosingClass = res2.javaClass.enclosingClass
if (enclosingClass?.name != "InlineChain2_1Kt\$box$\$inlined\$call\$lambda\$lambda$2") return "fail 2: ${enclosingClass?.name}"
return res2()
}
@@ -0,0 +1,5 @@
package test
inline fun <R> call(crossinline s: () -> R) = { s() }()
inline fun test(crossinline z: () -> String) = { z() }