JVM_IR: try to fix SyntheticAccessorLowering.isAccessible again

The condition on the relationship between the current class and the type
of the receiver for protected members was the opposite of what the JVMS
says, and yet somehow mostly worked?

 #KT-48331 Fixed
 #KT-20542 Fixed
This commit is contained in:
pyos
2021-08-23 13:48:23 +02:00
committed by TeamCityServer
parent 9a472c418f
commit 7ce5556de3
15 changed files with 231 additions and 102 deletions
@@ -30,10 +30,6 @@ inline fun inlineMe(crossinline c: suspend () -> Unit) = object : SuspendRunnabl
StateMachineChecker.suspendHere()
StateMachineChecker.suspendHere()
}
// TODO: call it from run1
inline suspend fun inlineMeCapturing() {
c(); c()
}
}
inline fun inlineMe2(crossinline c: suspend () -> Unit) = inlineMe { c(); c() }
@@ -0,0 +1,25 @@
// TARGET_BACKEND: JVM
// FILE: foo.kt
package foo
abstract class Base {
protected abstract fun foo(): String
}
// FILE: bar.kt
import foo.*
abstract class C : Base() {
class A : C() {
override fun foo() = "OK"
}
class B(val x: C) : C() {
// Needs an accessor (`foo` is in another package and `x` is not assignable to `B`)
override fun foo() = x.foo()
fun bar() = foo()
}
}
fun box() = C.B(C.A()).bar()
@@ -0,0 +1,16 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// FILE: x.kt
package x
internal class C {
// `foo$default` generated as package-private (not protected):
private fun foo(result: String = "OK") = result
// this needs an accessor:
internal inline fun bar() = foo()
}
// FILE: y.kt
import x.*
fun box() = C().bar()
@@ -0,0 +1,11 @@
// TARGET_BACKEND: JVM
open class C {
protected open fun foo() = "OK"
}
class D : C() {
// same package, but `super` needs to be related by class hierarchy:
fun bar() = { super.foo() }
}
fun box() = D().bar()()