[NI] Fix hierarchy of resolution atoms for lambda with non-local return
This commit is contained in:
+8
-9
@@ -123,18 +123,17 @@ class KotlinResolutionCallbacksImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasReturnWithoutExpression) {
|
val lastExpressionArgument = getLastDeparentesizedExpression(psiCallArgument)?.let { lastExpression ->
|
||||||
val lastExpressionArgument = getLastDeparentesizedExpression(psiCallArgument)?.let { lastExpression ->
|
if (expectedReturnType?.isUnit() == true) return@let null // coercion to Unit
|
||||||
if (expectedReturnType?.isUnit() == true) return@let null // coercion to Unit
|
|
||||||
|
|
||||||
// todo lastExpression can be if without else
|
// todo lastExpression can be if without else
|
||||||
val lastExpressionType = trace.getType(lastExpression)
|
val lastExpressionType = if (hasReturnWithoutExpression) null else trace.getType(lastExpression)
|
||||||
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, lambdaInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
|
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, lambdaInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
|
||||||
createCallArgument(lastExpression, lastExpressionTypeInfo)
|
createCallArgument(lastExpression, lastExpressionTypeInfo)
|
||||||
}
|
|
||||||
returnArguments.addIfNotNull(lastExpressionArgument)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
returnArguments.addIfNotNull(lastExpressionArgument)
|
||||||
|
|
||||||
return returnArguments
|
return returnArguments
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
fun <T> outer(command: () -> T) : T = command()
|
||||||
|
|
||||||
|
inline fun <K> inner(action: () -> K): K = action()
|
||||||
|
|
||||||
|
fun test1(): String {
|
||||||
|
outer {
|
||||||
|
inner {
|
||||||
|
return@outer
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "O"
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test2(): String {
|
||||||
|
outer {
|
||||||
|
return@outer
|
||||||
|
inner {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return "K"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
return test1() + test2()
|
||||||
|
}
|
||||||
+6
@@ -12422,6 +12422,12 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("returnInsideTwoLambdas.kt")
|
||||||
|
public void testReturnInsideTwoLambdas() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/returnInsideTwoLambdas.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("use.kt")
|
@TestMetadata("use.kt")
|
||||||
public void testUse() throws Exception {
|
public void testUse() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
||||||
|
|||||||
@@ -12422,6 +12422,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("returnInsideTwoLambdas.kt")
|
||||||
|
public void testReturnInsideTwoLambdas() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/returnInsideTwoLambdas.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("use.kt")
|
@TestMetadata("use.kt")
|
||||||
public void testUse() throws Exception {
|
public void testUse() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
||||||
|
|||||||
@@ -12422,6 +12422,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("returnInsideTwoLambdas.kt")
|
||||||
|
public void testReturnInsideTwoLambdas() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/returnInsideTwoLambdas.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("use.kt")
|
@TestMetadata("use.kt")
|
||||||
public void testUse() throws Exception {
|
public void testUse() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
||||||
|
|||||||
@@ -13484,6 +13484,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("returnInsideTwoLambdas.kt")
|
||||||
|
public void testReturnInsideTwoLambdas() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/returnInsideTwoLambdas.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("use.kt")
|
@TestMetadata("use.kt")
|
||||||
public void testUse() throws Exception {
|
public void testUse() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user