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:
Dmitry Savvinov
2019-08-12 12:26:50 +03:00
parent 555e1a35e9
commit 0065236bde
8 changed files with 16 additions and 20 deletions
@@ -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