Choose proper context for accessor generation: skip inline ones; Fix for KT-6102: Bypass synthetic accessor when inlining lambda which calls private member
#KT-6102 Fixed
This commit is contained in:
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
import test.*
|
||||
|
||||
class A {
|
||||
|
||||
private val prop : String = "O"
|
||||
get() = call {field + "K" }
|
||||
|
||||
private val prop2 : String = "O"
|
||||
get() = call { call {field + "K" } }
|
||||
|
||||
fun test1(): String {
|
||||
return prop
|
||||
}
|
||||
|
||||
fun test2(): String {
|
||||
return prop2
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.test1() != "OK") return "fail 1: ${a.test1()}"
|
||||
return a.test2()
|
||||
}
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
inline fun call(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
class A {
|
||||
|
||||
private val prop : String = "O"
|
||||
get() = call {field + "K" }
|
||||
|
||||
private val prop2 : String = "O"
|
||||
get() = call { call {field + "K" } }
|
||||
|
||||
fun test1(): String {
|
||||
return prop
|
||||
}
|
||||
|
||||
fun test2(): String {
|
||||
return prop2
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.test1() != "OK") return "fail 1: ${a.test1()}"
|
||||
return a.test2()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
inline fun call(crossinline s: () -> String): String {
|
||||
return { s() } ()
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import test.*
|
||||
|
||||
class A {
|
||||
|
||||
private fun method() = "O"
|
||||
|
||||
private val prop = "K"
|
||||
|
||||
fun test1(): String {
|
||||
return call {
|
||||
method() + prop
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(): String {
|
||||
return call {
|
||||
call {
|
||||
method() + prop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.test1() != "OK") return "fail 1: ${a.test1()}"
|
||||
return a.test2()
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package test
|
||||
|
||||
inline fun call(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
class A {
|
||||
|
||||
private fun method() = "O"
|
||||
|
||||
private val prop = "K"
|
||||
|
||||
fun test1(): String {
|
||||
return call {
|
||||
method() + prop
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(): String {
|
||||
return call {
|
||||
call {
|
||||
method() + prop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.test1() != "OK") return "fail 1: ${a.test1()}"
|
||||
return a.test2()
|
||||
}
|
||||
Vendored
+7
@@ -0,0 +1,7 @@
|
||||
package test
|
||||
|
||||
inline fun call(crossinline s: () -> String): String {
|
||||
return {
|
||||
s()
|
||||
}()
|
||||
}
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import test.*
|
||||
|
||||
class A : Base() {
|
||||
|
||||
override fun method() = "fail method"
|
||||
|
||||
override val prop = "fail property"
|
||||
|
||||
fun test1(): String {
|
||||
return call {
|
||||
super.method() + super.prop
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(): String {
|
||||
return call {
|
||||
call {
|
||||
super.method() + super.prop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.test1() != "OK") return "fail 1: ${a.test1()}"
|
||||
return a.test2()
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package test
|
||||
|
||||
inline fun call(s: () -> String): String {
|
||||
return s()
|
||||
}
|
||||
|
||||
open class Base {
|
||||
|
||||
protected open fun method(): String = "O"
|
||||
|
||||
protected open val prop = "K"
|
||||
}
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
//NO_CHECK_LAMBDA_INLINING
|
||||
import test.*
|
||||
|
||||
class A : Base() {
|
||||
|
||||
override fun method() = "fail method"
|
||||
|
||||
override val prop = "fail property"
|
||||
|
||||
fun test1(): String {
|
||||
return call {
|
||||
super.method() + super.prop
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(): String {
|
||||
return call {
|
||||
call {
|
||||
super.method() + super.prop
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val a = A()
|
||||
if (a.test1() != "OK") return "fail 1: ${a.test1()}"
|
||||
return a.test2()
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
package test
|
||||
|
||||
inline fun call(crossinline s: () -> String): String {
|
||||
return {
|
||||
s()
|
||||
}()
|
||||
}
|
||||
|
||||
open class Base {
|
||||
|
||||
protected open fun method(): String = "O"
|
||||
|
||||
protected open val prop = "K"
|
||||
}
|
||||
Reference in New Issue
Block a user