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:
@@ -27,10 +27,6 @@ import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
level = DeprecationLevel.ERROR
|
||||
)
|
||||
interface JsPlatform : TargetPlatform {
|
||||
@JvmDefault
|
||||
override val platformName: String
|
||||
get() = "JS"
|
||||
|
||||
companion object {
|
||||
@JvmField
|
||||
val INSTANCE: JsPlatform = JsPlatforms.CompatJsPlatform
|
||||
|
||||
@@ -24,7 +24,10 @@ object JsPlatforms {
|
||||
)
|
||||
object CompatJsPlatform : TargetPlatform(setOf(DefaultSimpleJsPlatform)),
|
||||
// Needed for backward compatibility, because old code uses INSTANCEOF checks instead of calling extensions
|
||||
org.jetbrains.kotlin.js.resolve.JsPlatform {}
|
||||
org.jetbrains.kotlin.js.resolve.JsPlatform {
|
||||
override val platformName: String
|
||||
get() = "JS"
|
||||
}
|
||||
|
||||
val defaultJsPlatform: TargetPlatform
|
||||
get() = CompatJsPlatform
|
||||
|
||||
Reference in New Issue
Block a user