[FIR] KT-55666: Support labels to local functions
^KT-55666 Fixed
This commit is contained in:
committed by
Space Team
parent
f4cda71d9e
commit
ff96033e95
+6
@@ -507,6 +507,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
|
|||||||
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
|
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt55666.kt")
|
||||||
|
public void testKt55666() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/kt55666.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt55733.kt")
|
@TestMetadata("kt55733.kt")
|
||||||
public void testKt55733() throws Exception {
|
public void testKt55733() throws Exception {
|
||||||
|
|||||||
+6
@@ -507,6 +507,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
|
|||||||
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
|
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt55666.kt")
|
||||||
|
public void testKt55666() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/kt55666.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt55733.kt")
|
@TestMetadata("kt55733.kt")
|
||||||
public void testKt55733() throws Exception {
|
public void testKt55733() throws Exception {
|
||||||
|
|||||||
+6
@@ -507,6 +507,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
|
|||||||
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
|
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt55666.kt")
|
||||||
|
public void testKt55666() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/kt55666.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt55733.kt")
|
@TestMetadata("kt55733.kt")
|
||||||
public void testKt55733() throws Exception {
|
public void testKt55733() throws Exception {
|
||||||
|
|||||||
+1
-1
@@ -1676,7 +1676,7 @@ class DeclarationsConverter(
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
val functionName = identifier.nameAsSafeName()
|
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)
|
target = FirFunctionTarget(labelName, isLambda = false)
|
||||||
functionSymbol = FirNamedFunctionSymbol(callableIdForName(functionName))
|
functionSymbol = FirNamedFunctionSymbol(callableIdForName(functionName))
|
||||||
FirSimpleFunctionBuilder().apply {
|
FirSimpleFunctionBuilder().apply {
|
||||||
|
|||||||
@@ -1435,7 +1435,7 @@ open class RawFirBuilder(
|
|||||||
FirSimpleFunctionBuilder().apply {
|
FirSimpleFunctionBuilder().apply {
|
||||||
receiverParameter = receiverType?.convertToReceiverParameter()
|
receiverParameter = receiverType?.convertToReceiverParameter()
|
||||||
name = function.nameAsSafeName
|
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 }
|
symbol = FirNamedFunctionSymbol(callableIdForName(function.nameAsSafeName)).also { functionSymbol = it }
|
||||||
dispatchReceiverType = currentDispatchReceiverType()
|
dispatchReceiverType = currentDispatchReceiverType()
|
||||||
status = FirDeclarationStatusImpl(
|
status = FirDeclarationStatusImpl(
|
||||||
|
|||||||
+19
@@ -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()
|
||||||
|
}
|
||||||
@@ -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
|
||||||
Generated
+6
@@ -507,6 +507,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
|
|||||||
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
|
runTest("compiler/testData/diagnostics/tests/kt55181.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("kt55666.kt")
|
||||||
|
public void testKt55666() throws Exception {
|
||||||
|
runTest("compiler/testData/diagnostics/tests/kt55666.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("kt55733.kt")
|
@TestMetadata("kt55733.kt")
|
||||||
public void testKt55733() throws Exception {
|
public void testKt55733() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user