JVM_IR: further refine synthetic accessor generation

References to protected members from crossinline lambdas in the same
package do not need accessors.
This commit is contained in:
pyos
2020-01-28 14:18:44 +01:00
committed by max-kammerer
parent 21d3adf084
commit bda5b0d5a9
17 changed files with 154 additions and 60 deletions
@@ -0,0 +1,19 @@
// FILE: protectedPack/J.java
package protectedPack;
public class J {
protected String foo = "OK";
}
// FILE: 1.kt
package protectedPack
inline fun foo(crossinline bar: () -> String) = object {
fun baz() = bar()
}.baz()
fun box(): String {
return foo { J().foo!! }
}
@@ -0,0 +1,31 @@
// !LANGUAGE: -ProhibitProtectedCallFromInline
// IGNORE_BACKEND: JVM
// IGNORE_BACKEND_MULTI_MODULE: JVM
// FILE: 1.kt
package test
inline fun runCrossinline(crossinline f: () -> String) = f()
open class Base {
protected open val FOO = "O"
protected open fun test() = "K"
}
open class P : Base() {
inline fun protectedProp(crossinline f: (String) -> String): String =
runCrossinline { f(FOO) }
inline fun protectedFun(crossinline f: (String) -> String): String =
runCrossinline { f(test()) }
}
// FILE: 2.kt
import test.*
fun box() : String {
val p = P()
return p.protectedProp { it } + p.protectedFun { it }
}
@@ -0,0 +1,17 @@
package a
open class A {
protected fun protectedFun(): String = "OK"
}
inline fun foo(crossinline bar: () -> String) = object {
fun baz() = bar()
}.baz()
class BSamePackage: A() {
fun test(): String = foo {
protectedFun()
}
}
// 0 INVOKESTATIC a/BSamePackage.access