diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 740ad589eb6..33adc17588d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -29170,6 +29170,12 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/script/SimpleScript.kts"); } + @Test + @TestMetadata("topLevelInlineFun.kts") + public void testTopLevelInlineFun() throws Exception { + runTest("compiler/testData/diagnostics/tests/script/topLevelInlineFun.kts"); + } + @Test @TestMetadata("topLevelPropertiesWithGetSet.kts") public void testTopLevelPropertiesWithGetSet() throws Exception { diff --git a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/FirJvmInlineCheckerComponent.kt b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/FirJvmInlineCheckerComponent.kt index 9c5db159d66..a02d6f18e28 100644 --- a/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/FirJvmInlineCheckerComponent.kt +++ b/compiler/fir/checkers/checkers.jvm/src/org/jetbrains/kotlin/fir/analysis/jvm/checkers/FirJvmInlineCheckerComponent.kt @@ -22,7 +22,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirValueParameterSymbol class FirJvmInlineCheckerComponent : FirInlineCheckerPlatformSpecificComponent() { override fun isGenerallyOk(declaration: FirDeclaration, context: CheckerContext, reporter: DiagnosticReporter): Boolean { // local inline functions are prohibited - return if (declaration.isLocalMember) { + return if (declaration.isLocalMember && context.containingDeclarations.lastOrNull() !is FirScript) { reporter.reportOn(declaration.source, FirErrors.NOT_YET_SUPPORTED_IN_INLINE, "Local inline functions", context) false } else { diff --git a/compiler/testData/codegen/script/inline.kts b/compiler/testData/codegen/script/inline.kts index c071392a371..036cdf8514c 100644 --- a/compiler/testData/codegen/script/inline.kts +++ b/compiler/testData/codegen/script/inline.kts @@ -1,4 +1,3 @@ -// IGNORE_BACKEND_K2: JVM_IR // expected: rv: 2 inline fun foo(l: (Int) -> Int ): Int { diff --git a/compiler/testData/diagnostics/tests/script/topLevelInlineFun.kts b/compiler/testData/diagnostics/tests/script/topLevelInlineFun.kts new file mode 100644 index 00000000000..b79c2ece814 --- /dev/null +++ b/compiler/testData/diagnostics/tests/script/topLevelInlineFun.kts @@ -0,0 +1,5 @@ +// FIR_IDENTICAL + +inline fun foo(f: () -> Unit) { + f() +} diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 18560d21b3e..e2bb5a0e0a0 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -30008,6 +30008,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/script/SimpleScript.kts"); } + @Test + @TestMetadata("topLevelInlineFun.kts") + public void testTopLevelInlineFun() throws Exception { + runTest("compiler/testData/diagnostics/tests/script/topLevelInlineFun.kts"); + } + @Test @TestMetadata("topLevelPropertiesWithGetSet.kts") public void testTopLevelPropertiesWithGetSet() throws Exception {