[K/JS] Forbid capture of inlinable functions inside js-code since 2.3 with error ^KT-78360 Fixed
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/inlineFunctionWithMultipleParameters.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/inlineFunctionWithMultipleParameters.kt
index 765ce06..da70662 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/inlineFunctionWithMultipleParameters.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/inlineFunctionWithMultipleParameters.kt
@@ -11,9 +11,9 @@
noinline block2: () -> Unit,
block3: () -> Unit
) {
- js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block1()"<!>)
+ js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block1()"<!>)
js("block2()")
- js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block3()"<!>)
+ js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block3()"<!>)
}
fun box(): String {
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/lambdaPassedToInlineFunction.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/lambdaPassedToInlineFunction.kt
index 04bd7bd..de383d7 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/lambdaPassedToInlineFunction.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/lambdaPassedToInlineFunction.kt
@@ -10,7 +10,7 @@
@Retention(AnnotationRetention.SOURCE)
public annotation class SomeAnnotation
-inline fun foo(block: () -> Unit) = js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block()"<!>)
+inline fun foo(block: () -> Unit) = js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block()"<!>)
fun box(): String {
val visited = mutableListOf<Pair<Int, Int>>()
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/loopWithinInlineFunction.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/loopWithinInlineFunction.kt
index 7c5d99e..2ea1cd9 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/loopWithinInlineFunction.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/loopWithinInlineFunction.kt
@@ -7,7 +7,7 @@
import kotlin.test.assertEquals
inline fun <T> Iterable<T>.myForEach(action: (T) -> Unit): Unit {
- for (element in this) js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"action(element)"<!>)
+ for (element in this) js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"action(element)"<!>)
}
private fun testMyForEach() {
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/nonLocalReturn.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/nonLocalReturn.fir.kt
index 8a94348..8fe18fd 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/nonLocalReturn.fir.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/nonLocalReturn.fir.kt
@@ -1,7 +1,7 @@
// ISSUE: KT-68975
// LANGUAGE: +IrInlinerBeforeKlibSerialization
inline fun foo(makeInt: () -> Int): Int {
- return js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"makeInt()"<!>)
+ return js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"makeInt()"<!>)
}
fun box(): String {
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/simple.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/simple.kt
index 0f9245d..2ce6e23 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/simple.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/simple.kt
@@ -4,7 +4,7 @@
// ISSUE: KT-68975
// See same test for codegen: compiler/testData/codegen/box/js/inlinedReturnBreakContinue/simple.kt
-inline fun foo(block: () -> Unit) { js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block()"<!>) }
+inline fun foo(block: () -> Unit) { js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block()"<!>) }
fun box(): String {
while (true) {
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/simpleDoWhile.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/simpleDoWhile.kt
index 4853bfd..333ace7 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/simpleDoWhile.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/simpleDoWhile.kt
@@ -4,7 +4,7 @@
// ISSUE: KT-68975
// See same test for codegen: compiler/testData/codegen/box/js/inlinedReturnBreakContinue/simpleDoWhile.kt
-inline fun foo(block: () -> Unit) { js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block()"<!>) }
+inline fun foo(block: () -> Unit) { js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block()"<!>) }
fun box(): String {
var i = 0
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValue.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValue.kt
index a715a19..5340661 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValue.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValue.kt
@@ -4,7 +4,7 @@
// ISSUE: KT-68975
// See same test for codegen: compiler/testData/codegen/box/js/inlinedReturnBreakContinue/withReturnValue.kt
-inline fun foo(block: () -> Int): Int = js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block()"<!>)
+inline fun foo(block: () -> Int): Int = js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block()"<!>)
fun box(): String {
var sum = 0
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValueDoWhileContinue.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValueDoWhileContinue.kt
index 664dcd2..9aaeeda 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValueDoWhileContinue.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValueDoWhileContinue.kt
@@ -4,7 +4,7 @@
// ISSUE: KT-68975
// See same test for codegen: compiler/testData/codegen/box/js/inlinedReturnBreakContinue/withReturnValueDoWhileContinue.kt
-inline fun foo(block: () -> Int): Int = js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block()"<!>)
+inline fun foo(block: () -> Int): Int = js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block()"<!>)
fun box(): String {
var sum = 0
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValueNested.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValueNested.kt
index 1f57449..a106d08 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValueNested.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/inlinedReturnBreakContinue/withReturnValueNested.kt
@@ -4,7 +4,7 @@
// ISSUE: KT-68975
// See same test for codegen: compiler/testData/codegen/box/js/inlinedReturnBreakContinue/withReturnValueNested.kt
-inline fun foo(block: () -> Int): Int = js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block()"<!>)
+inline fun foo(block: () -> Int): Int = js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block()"<!>)
fun box(): String {
val resultNonLabeled = testNonLabeledBreaks()
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/jsCallCaptureInlinableFunction.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/jsCallCaptureInlinableFunction.kt
index 852e377..4ca3aa6 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/jsCallCaptureInlinableFunction.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/jsCallCaptureInlinableFunction.kt
@@ -18,9 +18,9 @@
crossinline crossInlineOne: () -> String,
noinline noInlineOne: () -> List<Int>
) {
- js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>JS_CODE<!>)
- js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"console.log('The second is: ' + secondFunction());"<!>)
- js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"console.log('The third results is: ' + crossInlineOne());"<!>)
+ js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>JS_CODE<!>)
+ js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"console.log('The second is: ' + secondFunction());"<!>)
+ js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"console.log('The third results is: ' + crossInlineOne());"<!>)
js("""
var thirdWhichWillBeShadowed = 44;
console.log("The valid result should be: " + noInlineOne() + ", " + thirdWhichWillBeShadowed());
@@ -58,8 +58,8 @@
var usageOfTheFirstValue = value + 4;
var usageOfTheComplexValue = complexValue[4];
""")
- js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"console.log('The first result is: ' + firstFunction());"<!>)
- js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"console.log('The third results is: ' + crossInlineOne());"<!>)
+ js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"console.log('The first result is: ' + firstFunction());"<!>)
+ js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"console.log('The third results is: ' + crossInlineOne());"<!>)
js("""
var thirdWhichWillBeShadowed = 44;
console.log("The valid result should be: " + noInlineOne() + ", " + thirdWhichWillBeShadowed());
diff --git a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/lambdaWithoutNonLocalControlflow.fir.kt b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/lambdaWithoutNonLocalControlflow.fir.kt
index f49918e..be10c9a 100644
--- a/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/lambdaWithoutNonLocalControlflow.fir.kt
+++ b/compiler/testData/diagnostics/testsWithJsStdLibAndBackendCompilation/jsCode/lambdaWithoutNonLocalControlflow.fir.kt
@@ -8,7 +8,7 @@
inline fun testLambdaInline(
block: (Unit) -> String,
): String {
- return js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block()"<!>)
+ return js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block()"<!>)
}
<!NOTHING_TO_INLINE!>inline<!> fun testLambdaNoInline(
@@ -20,7 +20,7 @@
inline fun testLambdaCrossInline(
crossinline block: (Unit) -> String,
): String {
- return js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_WARNING!>"block()"<!>)
+ return js(<!JS_CODE_CAPTURES_INLINABLE_FUNCTION_ERROR!>"block()"<!>)
}
fun box(): String {
diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt
index 2ee3333..22c2797 100644
--- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt
+++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt
@@ -436,11 +436,11 @@
ParseLambdaWithSuspendModifier(KOTLIN_2_3, "KT-22765"),
DiscriminateSuspendInOverloadResolution(KOTLIN_2_3, "KT-23610"),
JsAllowLongInExportedDeclarations(sinceVersion = KOTLIN_2_3, "KT-79222"),
+ ForbidCaptureInlinableLambdasInJsCode(KOTLIN_2_3, enabledInProgressiveMode = true, "KT-69297"),
// 2.4
ForbidExposingLessVisibleTypesInInline(KOTLIN_2_4, enabledInProgressiveMode = true, "KTLC-283"),
- ForbidCaptureInlinableLambdasInJsCode(KOTLIN_2_4, enabledInProgressiveMode = true, "KT-69297"),
ForbidInitializationBeforeDeclarationInAnonymous(KOTLIN_2_4, enabledInProgressiveMode = true, "KT-77156"),
AllowReifiedTypeInCatchClause(KOTLIN_2_4, issue = "KT-54363"),
ForbidGetSetValueWithTooManyParameters(KOTLIN_2_4, issue = "KT-77131"),