rra/ilgonmic/eager-like-native

[JS IR] Leave JsEagerInitialization until bootstrap update

[JS IR] Fix js stdlib api

[JS IR] Change annotation on eager initialization in sources

[JS IR] Make eager initialization consistent with native

Merge-request: KT-MR-5030
This commit is contained in:
Ilya Goncharov
2021-11-22 12:45:37 +00:00
committed by Space
parent 24bc1fe1b4
commit f48436b35e
10 changed files with 31 additions and 34 deletions
@@ -288,7 +288,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
val doNotIntrinsifyAnnotationSymbol = context.symbolTable.referenceClass(context.getJsInternalClass("DoNotIntrinsify"))
val jsFunAnnotationSymbol = context.symbolTable.referenceClass(context.getJsInternalClass("JsFun"))
val jsEagerInitializationAnnotationSymbol = context.symbolTable.referenceClass(context.getJsInternalClass("JsEagerInitialization"))
val jsEagerInitializationAnnotationSymbol = context.symbolTable.referenceClass(context.getJsInternalClass("EagerInitialization"))
// TODO move CharSequence-related stiff to IntrinsifyCallsLowering
val charSequenceClassSymbol = context.symbolTable.referenceClass(context.getClass(FqName("kotlin.CharSequence")))
@@ -9,7 +9,7 @@ var z2 = false
// FILE: lib2.kt
@OptIn(kotlin.ExperimentalStdlibApi::class)
@JsEagerInitialization
@EagerInitialization
val x = foo()
private fun foo(): Int {
@@ -9,7 +9,7 @@ var z2 = false
// FILE: lib2.kt
@OptIn(kotlin.ExperimentalStdlibApi::class)
@JsEagerInitialization
@EagerInitialization
val x = run { z1 = true; 42 }
// Won't be initialized (cause no function from the file will be called during [x] initialization).
@@ -8,7 +8,7 @@ var z1 = false
// FILE: lib2.kt
@OptIn(kotlin.ExperimentalStdlibApi::class)
@JsEagerInitialization
@EagerInitialization
val x = run { z1 = !z1; 42 }
val y = run { 73 }
+1 -1
View File
@@ -17,7 +17,7 @@ fun raise(name: String): Nothing {
// Adapter should be initialized eagerly
@Suppress("INVISIBLE_MEMBER")
@OptIn(kotlin.ExperimentalStdlibApi::class)
@JsEagerInitialization
@EagerInitialization
private val underscore = kotlin.test.setAdapter(object : FrameworkAdapter {
override fun suite(name: String, ignored: Boolean, suiteFn: () -> Unit) {
sortingContext.suite(name, ignored) { suiteFn() }
+9 -8
View File
@@ -193,6 +193,15 @@ public final external class Date {
}
}
@kotlin.ExperimentalStdlibApi
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.PROPERTY})
@kotlin.SinceKotlin(version = "1.6")
@kotlin.Deprecated(message = "This annotation is a temporal migration assistance and may be removed in the future releases, please consider filing an issue about the case where it is needed")
public final annotation class EagerInitialization : kotlin.Annotation {
public constructor EagerInitialization()
}
@kotlin.RequiresOptIn(level = Level.WARNING)
@kotlin.annotation.MustBeDocumented
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@@ -225,14 +234,6 @@ public external interface JsClass<T : kotlin.Any> {
public abstract val name: kotlin.String { get; }
}
@kotlin.ExperimentalStdlibApi
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.PROPERTY})
@kotlin.SinceKotlin(version = "1.6")
public final annotation class JsEagerInitialization : kotlin.Annotation {
public constructor JsEagerInitialization()
}
@kotlin.js.ExperimentalJsExport
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.FILE})
+9 -8
View File
@@ -192,6 +192,15 @@ public final external class Date {
}
}
@kotlin.ExperimentalStdlibApi
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.PROPERTY})
@kotlin.SinceKotlin(version = "1.6")
@kotlin.Deprecated(message = "This annotation is a temporal migration assistance and may be removed in the future releases, please consider filing an issue about the case where it is needed")
public final annotation class EagerInitialization : kotlin.Annotation {
public constructor EagerInitialization()
}
@kotlin.RequiresOptIn(level = Level.WARNING)
@kotlin.annotation.MustBeDocumented
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@@ -224,14 +233,6 @@ public external interface JsClass<T : kotlin.Any> {
public abstract val name: kotlin.String { get; }
}
@kotlin.ExperimentalStdlibApi
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.PROPERTY})
@kotlin.SinceKotlin(version = "1.6")
public final annotation class JsEagerInitialization : kotlin.Annotation {
public constructor JsEagerInitialization()
}
@kotlin.js.ExperimentalJsExport
@kotlin.annotation.Retention(value = AnnotationRetention.BINARY)
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.PROPERTY, AnnotationTarget.FUNCTION, AnnotationTarget.FILE})
@@ -63,14 +63,4 @@ public annotation class ExperimentalJsExport
@Target(CLASS, PROPERTY, FUNCTION, FILE)
@SinceKotlin("1.4")
@OptionalExpectation
public expect annotation class JsExport()
/**
* Forces a top-level property to be initialized eagerly, opposed to lazily on the first access to file and/or property.
*/
@ExperimentalStdlibApi
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.PROPERTY)
@SinceKotlin("1.6")
@OptionalExpectation
public expect annotation class JsEagerInitialization
public expect annotation class JsExport()
@@ -199,4 +199,8 @@ public actual annotation class JsExport
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.PROPERTY)
@SinceKotlin("1.6")
public actual annotation class JsEagerInitialization
@Deprecated("This annotation is a temporal migration assistance and may be removed in the future releases, please consider filing an issue about the case where it is needed")
public annotation class EagerInitialization
@Deprecated("It is necessary until bootstrap update", level = DeprecationLevel.HIDDEN)
internal annotation class JsEagerInitialization
+2 -1
View File
@@ -9,4 +9,5 @@ package kotlin.js
@Retention(AnnotationRetention.BINARY)
@Target(AnnotationTarget.PROPERTY)
@SinceKotlin("1.6")
public actual annotation class JsEagerInitialization
@Deprecated("This annotation is a temporal migration assistance and may be removed in the future releases, please consider filing an issue about the case where it is needed")
public annotation class EagerInitialization