K2 Scripting: allow script top level inline functions

This commit is contained in:
Ilya Chernikov
2023-05-25 16:37:44 +02:00
committed by Space Team
parent 86b3e65d19
commit 7484ccb9ee
5 changed files with 18 additions and 2 deletions
@@ -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 {
@@ -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 {
-1
View File
@@ -1,4 +1,3 @@
// IGNORE_BACKEND_K2: JVM_IR
// expected: rv: 2
inline fun foo(l: (Int) -> Int ): Int {
@@ -0,0 +1,5 @@
// FIR_IDENTICAL
inline fun foo(f: () -> Unit) {
f()
}
@@ -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 {