Fix for KT-10729: Accessing private const field in companion object from a function in the same companion generates run-time error
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
class My {
|
||||
companion object {
|
||||
private val my: String = "O"
|
||||
get() = field + "K"
|
||||
|
||||
fun getValue() = my
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = My.getValue()
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class My {
|
||||
companion object {
|
||||
private val my: String = "O"
|
||||
get() = { field }() + "K"
|
||||
|
||||
fun getValue() = my
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = My.getValue()
|
||||
@@ -0,0 +1,20 @@
|
||||
class IntentionsBundle {
|
||||
companion object {
|
||||
fun message(key: String): String {
|
||||
return key + BUNDLE
|
||||
}
|
||||
|
||||
fun message2(key: String): String {
|
||||
return { key + BUNDLE }()
|
||||
}
|
||||
|
||||
private const val BUNDLE = "K"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun box(): String {
|
||||
if (IntentionsBundle.message("O") != "OK") return "fail 1: ${IntentionsBundle.message("O")}"
|
||||
|
||||
return IntentionsBundle.message2("O")
|
||||
}
|
||||
Reference in New Issue
Block a user