[FIR] KT-55666: Support labels to local functions

^KT-55666 Fixed
This commit is contained in:
Nikolay Lunyak
2023-01-18 13:28:52 +02:00
committed by Space Team
parent f4cda71d9e
commit ff96033e95
8 changed files with 50 additions and 2 deletions
@@ -507,6 +507,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
}
@Test
@TestMetadata("kt55666.kt")
public void testKt55666() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt55666.kt");
}
@Test
@TestMetadata("kt55733.kt")
public void testKt55733() throws Exception {
@@ -507,6 +507,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
}
@Test
@TestMetadata("kt55666.kt")
public void testKt55666() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt55666.kt");
}
@Test
@TestMetadata("kt55733.kt")
public void testKt55733() throws Exception {
@@ -507,6 +507,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
}
@Test
@TestMetadata("kt55666.kt")
public void testKt55666() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt55666.kt");
}
@Test
@TestMetadata("kt55733.kt")
public void testKt55733() throws Exception {
@@ -1676,7 +1676,7 @@ class DeclarationsConverter(
}
} else {
val functionName = identifier.nameAsSafeName()
val labelName = runIf(!functionName.isSpecial) { functionName.identifier }
val labelName = context.getLastLabel(functionDeclaration)?.name ?: runIf(!functionName.isSpecial) { functionName.identifier }
target = FirFunctionTarget(labelName, isLambda = false)
functionSymbol = FirNamedFunctionSymbol(callableIdForName(functionName))
FirSimpleFunctionBuilder().apply {
@@ -1435,7 +1435,7 @@ open class RawFirBuilder(
FirSimpleFunctionBuilder().apply {
receiverParameter = receiverType?.convertToReceiverParameter()
name = function.nameAsSafeName
labelName = runIf(!name.isSpecial) { name.identifier }
labelName = context.getLastLabel(function)?.name ?: runIf(!name.isSpecial) { name.identifier }
symbol = FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName)).also { functionSymbol = it }
dispatchReceiverType = currentDispatchReceiverType()
status = FirDeclarationStatusImpl(
+19
View File
@@ -0,0 +1,19 @@
// FIR_IDENTICAL
inline fun l2f1(p: () -> Unit) {}
fun label2simple1() {
l2f1 { return@label2simple1 }
fun local() {
l2f1 { return@local }
}
labelLocal@ fun labelledLocal() {
l2f1 { return@labelLocal }
}
}
fun main() {
label2simple1()
}
+5
View File
@@ -0,0 +1,5 @@
package
public inline fun l2f1(/*0*/ p: () -> kotlin.Unit): kotlin.Unit
public fun label2simple1(): kotlin.Unit
public fun main(): kotlin.Unit
@@ -507,6 +507,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
}
@Test
@TestMetadata("kt55666.kt")
public void testKt55666() throws Exception {
runTest("compiler/testData/diagnostics/tests/kt55666.kt");
}
@Test
@TestMetadata("kt55733.kt")
public void testKt55733() throws Exception {