Support inline for private @JvmDefault members

This commit is contained in:
Mikhael Bogdanov
2018-02-27 12:15:55 +01:00
parent affe445955
commit d84a15c0f6
4 changed files with 73 additions and 1 deletions
@@ -0,0 +1,27 @@
// !API_VERSION: 1.3
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface Test {
@kotlin.annotations.JvmDefault
fun test(): String {
return inlineFun { "O" }
}
fun testDefaultImpls(): String {
return inlineFun { "K" }
}
@kotlin.annotations.JvmDefault
private inline fun inlineFun(s: () -> String) = s()
}
class TestClass : Test {
}
fun box(): String {
val foo = TestClass()
return foo.test() + foo.testDefaultImpls()
}
@@ -0,0 +1,29 @@
// !API_VERSION: 1.3
// JVM_TARGET: 1.8
// WITH_RUNTIME
interface Test {
@kotlin.annotations.JvmDefault
fun test(): String {
return inlineProp
}
fun testDefaultImpls(): String {
return inlineProp
}
@kotlin.annotations.JvmDefault
private inline val inlineProp: String
get() = "OK"
}
class TestClass : Test {
}
fun box(): String {
val foo = TestClass()
if (foo.test() != "OK") return "fail: ${foo.test()}"
return foo.testDefaultImpls()
}