JVM_IR: remap calls to protected @JvmStatic in companions
Protected functions on unrelated classes cannot be called from outside the current package, so in general, we can only call the static proxy, not the original companion method. This has an ABI compatibility implication in that removing `@JvmStatic` from a protected companion method will require recompiling Kotlin use sites (of course, this is already source- and binary-incompatible from Java perspective). #KT-12063 Fixed
This commit is contained in:
@@ -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()
|
||||
Reference in New Issue
Block a user