Move default implementation of TargetPlatform.platformName to leaf classes
Otherwise, we have a static initialization loop, leading to null-leaks Removing default interface method indeed disconnects the loop, as per JVM Specification, "5.5 Initialization". See KT-33245 for detailed explanations ^KT-33245 Fixed
This commit is contained in:
@@ -45,7 +45,10 @@ object JvmPlatforms {
|
||||
)
|
||||
object CompatJvmPlatform : TargetPlatform(setOf(UNSPECIFIED_SIMPLE_JVM_PLATFORM)),
|
||||
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
|
||||
org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform {}
|
||||
org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform {
|
||||
override val platformName: String
|
||||
get() = "JVM"
|
||||
}
|
||||
}
|
||||
|
||||
class JdkPlatform(val targetVersion: JvmTarget) : JvmPlatform() {
|
||||
|
||||
@@ -16,10 +16,6 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
interface JvmPlatform : TargetPlatform {
|
||||
@JvmDefault
|
||||
override val platformName: String
|
||||
get() = "JVM"
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val INSTANCE: JvmPlatform = JvmPlatforms.CompatJvmPlatform
|
||||
|
||||
Reference in New Issue
Block a user