Keep inline transformation invariant: all captured parameters stored in topmost lambda/object
Fix for KT-8668: java.lang.ClassFormatError: Duplicate field name&signature (based on property access) #KT-8668 Fixed
This commit is contained in:
+7
@@ -0,0 +1,7 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
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) }()}
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
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"
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
inline fun <T> inlineFun(arg: T, f: (T) -> Unit) {
|
||||
f(arg)
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
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
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
|
||||
{
|
||||
f(arg)
|
||||
}()
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
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"
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
|
||||
{
|
||||
f(arg)
|
||||
}()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
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"
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
inline fun <T> inlineFun(arg: T, crossinline f: (T) -> Unit) {
|
||||
{
|
||||
f(arg)
|
||||
}()
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
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) }()}
|
||||
}
|
||||
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
B("O", "K").test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
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) }() }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
Vendored
+30
@@ -0,0 +1,30 @@
|
||||
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"
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
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"
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
Vendored
+24
@@ -0,0 +1,24 @@
|
||||
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"
|
||||
}
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
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"
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
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"
|
||||
}
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().box()
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
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"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
B("O", "fail").test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
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") }() }
|
||||
}
|
||||
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = "fail"
|
||||
B("O", "K").test { it -> result = it }
|
||||
return result
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
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) }() }
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
B("O", "K").test { it -> result += it }
|
||||
return if (result == "OOKK") "OK" else "fail: $result"
|
||||
}
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
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) }
|
||||
}
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
B("O", "K").test { it -> result += it }
|
||||
return if (result == "OOKK") "OK" else "fail: $result"
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
var result = ""
|
||||
B("O", "K").test { it -> result += it }
|
||||
return if (result == "startOOKK") "OK" else "fail: $result"
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
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()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return A().testCall()
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
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()
|
||||
}()
|
||||
}
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return Person("OK").sayName()
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
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()
|
||||
}
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
val res = Person("OK").sayName()
|
||||
if (res != "OKsubOK") return "fail: $res"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
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()
|
||||
}
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return Company("OK").sayName()
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
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()
|
||||
|
||||
}
|
||||
Vendored
+6
@@ -0,0 +1,6 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
fun box(): String {
|
||||
return Person("OK").sayName()
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
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()
|
||||
|
||||
Reference in New Issue
Block a user