[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 ->
|
||||
if (expectedReturnType?.isUnit() == true) return@let null // coercion to Unit
|
||||
val lastExpressionArgument = getLastDeparentesizedExpression(psiCallArgument)?.let { lastExpression ->
|
||||
if (expectedReturnType?.isUnit() == true) return@let null // coercion to Unit
|
||||
|
||||
// todo lastExpression can be if without else
|
||||
val lastExpressionType = trace.getType(lastExpression)
|
||||
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, lambdaInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
|
||||
createCallArgument(lastExpression, lastExpressionTypeInfo)
|
||||
}
|
||||
returnArguments.addIfNotNull(lastExpressionArgument)
|
||||
// todo lastExpression can be if without else
|
||||
val lastExpressionType = if (hasReturnWithoutExpression) null else trace.getType(lastExpression)
|
||||
val lastExpressionTypeInfo = KotlinTypeInfo(lastExpressionType, lambdaInfo.dataFlowInfoAfter ?: functionTypeInfo.dataFlowInfo)
|
||||
createCallArgument(lastExpression, lastExpressionTypeInfo)
|
||||
}
|
||||
|
||||
returnArguments.addIfNotNull(lastExpressionArgument)
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("returnInsideTwoLambdas.kt")
|
||||
public void testReturnInsideTwoLambdas() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/returnInsideTwoLambdas.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("use.kt")
|
||||
public void testUse() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
||||
|
||||
@@ -12422,6 +12422,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
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")
|
||||
public void testUse() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
||||
|
||||
@@ -12422,6 +12422,12 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
||||
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")
|
||||
public void testUse() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
||||
|
||||
@@ -13484,6 +13484,12 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest {
|
||||
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")
|
||||
public void testUse() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/nonLocalReturns/use.kt");
|
||||
|
||||
Reference in New Issue
Block a user