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:
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()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user