Minor, add a bit more tests for KT-12063

This commit is contained in:
Alexander Udalov
2021-03-31 00:07:00 +02:00
parent 66429cfb43
commit 1f7cef6f13
12 changed files with 238 additions and 23 deletions
@@ -0,0 +1,20 @@
// TARGET_BACKEND: JVM
// WITH_RUNTIME
// FILE: 1.kt
package a
open class A {
companion object {
@JvmStatic
protected fun foo(result: String = "OK"): String = result
}
}
// FILE: 2.kt
import a.*
class B : A() {
fun bar(): String = foo()
}
fun box() = B().bar()
@@ -0,0 +1,21 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// WITH_RUNTIME
// FILE: 1.kt
package a
open class A {
companion object {
@JvmStatic // Required to be accessible from subclasses of A in other packages.
protected fun foo() = "OK"
}
}
// FILE: 2.kt
import a.*
class B : A() {
fun bar() = foo() // calls static A.foo(), not inaccessible A.Companion.foo()
}
fun box() = B().bar()
@@ -0,0 +1,26 @@
// TARGET_BACKEND: JVM
// IGNORE_BACKEND: JVM
// WITH_RUNTIME
// FILE: 1.kt
package a
open class A {
companion object {
@JvmStatic
@get:JvmStatic
@set:JvmStatic
protected var foo = "Fail"
}
}
// FILE: 2.kt
import a.*
class B : A() {
fun bar(): String {
foo = "OK"
return foo
}
}
fun box() = B().bar()