Support accessors for private methods for default methods

This commit is contained in:
Mikhail Bogdanov
2020-03-27 17:14:01 +01:00
parent 7bcbae9826
commit 93b915c77a
12 changed files with 294 additions and 2 deletions
@@ -0,0 +1,34 @@
// !JVM_DEFAULT_MODE: all-compatibility
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
var storage = "fail"
interface Test {
private var foo: String
get() = storage
set(value) {
storage = value
}
private fun bar(): String {
return "K"
}
fun call(): String {
return {
foo = "O"
foo + bar()
} ()
}
}
class TestClass : Test {
}
fun box(): String {
return TestClass().call()
}
@@ -0,0 +1,25 @@
// !JVM_DEFAULT_MODE: all-compatibility
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface Test {
private val foo: String
get() = "O"
private fun bar(): String {
return "K"
}
companion object {
fun call(test: Test): String {
return test.foo + test.bar()
}
}
}
class TestClass : Test
fun box(): String {
return Test.call(TestClass())
}
@@ -0,0 +1,24 @@
// !JVM_DEFAULT_MODE: all-compatibility
// IGNORE_BACKEND_FIR: JVM_IR
// TARGET_BACKEND: JVM
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface Test {
fun test(): String {
return privateFun() + privateProp
}
private fun privateFun(): String {
return "O"
}
private val privateProp: String
get() = "K"
}
class TestImpl: Test
fun box(): String {
return TestImpl().test()
}