Make $default methods non-private, avoid generating accessors for them
#KT-5786 Fixed
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
class A {
|
||||
private fun Int.foo(other: Int = 5): Int = this + other
|
||||
|
||||
inner class B {
|
||||
fun bar() = 37.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = if (A().B().bar() == 42) "OK" else "Fail"
|
||||
@@ -0,0 +1,11 @@
|
||||
// KT-5786 NoSuchMethodError: no accessor for private fun with default arguments
|
||||
|
||||
class A {
|
||||
private fun foo(result: String = "OK"): String = result
|
||||
|
||||
companion object {
|
||||
fun bar() = A().foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun box() = A.bar()
|
||||
@@ -0,0 +1,16 @@
|
||||
var state: String = "Fail"
|
||||
|
||||
class A private(x: String = "OK") {
|
||||
init {
|
||||
state = x
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun foo() = A()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
A.foo()
|
||||
return state
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
var state: String = "Fail"
|
||||
|
||||
class A {
|
||||
private constructor(x: String = "OK") {
|
||||
state = x
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun foo() = A()
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
A.foo()
|
||||
return state
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fun box(): String {
|
||||
run {
|
||||
test("ok")
|
||||
test("ok", 200)
|
||||
}
|
||||
test("ok")
|
||||
test("ok", 300)
|
||||
|
||||
return "OK"
|
||||
}
|
||||
|
||||
private fun test(arg1: String, default: Int = 0) = Unit
|
||||
Reference in New Issue
Block a user