mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 00:21:32 +00:00
Support synthetic accessors for @JvmDefault members
(cherry picked from commit 308283e)
This commit is contained in:
36
compiler/testData/codegen/java8/box/jvm8/defaults/accessor.kt
vendored
Normal file
36
compiler/testData/codegen/java8/box/jvm8/defaults/accessor.kt
vendored
Normal 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()
|
||||
}
|
||||
26
compiler/testData/codegen/java8/box/jvm8/defaults/accessorFromCompanion.kt
vendored
Normal file
26
compiler/testData/codegen/java8/box/jvm8/defaults/accessorFromCompanion.kt
vendored
Normal 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())
|
||||
}
|
||||
26
compiler/testData/codegen/java8/box/jvm8/defaults/accessorsFromDefaultImpls.kt
vendored
Normal file
26
compiler/testData/codegen/java8/box/jvm8/defaults/accessorsFromDefaultImpls.kt
vendored
Normal 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()
|
||||
}
|
||||
24
compiler/testData/codegen/java8/box/jvm8/defaults/privateDefaultFromDefaultImpl.kt
vendored
Normal file
24
compiler/testData/codegen/java8/box/jvm8/defaults/privateDefaultFromDefaultImpl.kt
vendored
Normal 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()
|
||||
}
|
||||
23
compiler/testData/codegen/java8/box/jvm8/defaults/privateInDefaultImpls.kt
vendored
Normal file
23
compiler/testData/codegen/java8/box/jvm8/defaults/privateInDefaultImpls.kt
vendored
Normal 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()
|
||||
}
|
||||
Reference in New Issue
Block a user