Support synthetic accessors for @JvmDefault members

(cherry picked from commit 308283e)
This commit is contained in:
Mikhael Bogdanov
2018-02-23 13:19:48 +01:00
parent 4a0037850b
commit 5ba37fdff7
13 changed files with 214 additions and 21 deletions

View File

@@ -0,0 +1,36 @@
// !API_VERSION: 1.3
// JVM_TARGET: 1.8
// WITH_RUNTIME
var storage = "fail"
interface Test {
@kotlin.annotations.JvmDefault
private var foo: String
get() = storage
set(value) {
storage = value
}
@kotlin.annotations.JvmDefault
private fun bar(): String {
return "K"
}
@kotlin.annotations.JvmDefault
fun call(): String {
return {
foo = "O"
foo + bar()
} ()
}
}
class TestClass : Test {
}
fun box(): String {
return TestClass().call()
}

View File

@@ -0,0 +1,26 @@
// !API_VERSION: 1.3
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface Test {
@kotlin.annotations.JvmDefault
private val foo: String
get() = "O"
@kotlin.annotations.JvmDefault
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())
}

View File

@@ -0,0 +1,26 @@
// !API_VERSION: 1.3
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface Test {
@kotlin.annotations.JvmDefault
private val foo: String
get() = "O"
@kotlin.annotations.JvmDefault
private fun bar(): String {
return "K"
}
fun call(): String {
return { foo + bar()} ()
}
}
class TestClass : Test {
}
fun box(): String {
return TestClass().call()
}

View File

@@ -0,0 +1,24 @@
// !API_VERSION: 1.3
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface Test {
fun test(): String {
return privateFun() + privateProp
}
@kotlin.annotations.JvmDefault
private fun privateFun(): String {
return "O"
}
@kotlin.annotations.JvmDefault
private val privateProp: String
get() = "K"
}
class TestImpl: Test
fun box(): String {
return TestImpl().test()
}

View File

@@ -0,0 +1,23 @@
// !API_VERSION: 1.3
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface Test {
@kotlin.annotations.JvmDefault
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()
}