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:
Michael Bogdanov
2015-12-14 18:47:29 +03:00
parent 033698c51d
commit 9cad1a912a
22 changed files with 457 additions and 40 deletions
@@ -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()
}
@@ -0,0 +1,5 @@
package test
inline fun call(s: () -> String): String {
return s()
}
@@ -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()
}
@@ -0,0 +1,5 @@
package test
inline fun call(crossinline s: () -> String): String {
return { s() } ()
}
@@ -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()
}
@@ -0,0 +1,5 @@
package test
inline fun call(s: () -> String): String {
return s()
}
@@ -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()
}
@@ -0,0 +1,7 @@
package test
inline fun call(crossinline s: () -> String): String {
return {
s()
}()
}
@@ -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()
}
@@ -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"
}
@@ -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()
}
@@ -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"
}
@@ -0,0 +1,28 @@
inline fun call(s: () -> Unit) {
s()
}
class A {
private fun method() {}
private val prop = 1
fun test1() {
call {
method()
prop
}
}
fun test2() {
call {
call {
method()
prop
}
}
}
}
//0 access\$
@@ -0,0 +1,22 @@
inline fun call(s: () -> String): String {
return s()
}
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
}
}
//0 access\$
@@ -0,0 +1,36 @@
inline fun call(s: () -> Unit) {
s()
}
open class Base {
protected open fun method() {}
protected open val prop = 1
}
class A: Base() {
override fun method() {}
override val prop = 1
fun test1() {
call {
super.method()
super.prop
}
}
fun test2() {
call {
call {
super.method()
super.prop
}
}
}
}
//0 access\$