[FIR LT] Add proper source for when with subject
#KT-56982 Fixed
This commit is contained in:
+6
@@ -535,6 +535,12 @@ public class FirLightTreeSteppingTestGenerated extends AbstractFirLightTreeStepp
|
||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenExpr.kt")
|
||||
public void testWhenExpr() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenIsChecks.kt")
|
||||
public void testWhenIsChecks() throws Exception {
|
||||
|
||||
+6
@@ -535,6 +535,12 @@ public class FirPsiSteppingTestGenerated extends AbstractFirPsiSteppingTest {
|
||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenExpr.kt")
|
||||
public void testWhenExpr() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenIsChecks.kt")
|
||||
public void testWhenIsChecks() throws Exception {
|
||||
|
||||
+16
-13
@@ -835,22 +835,24 @@ class ExpressionsConverter(
|
||||
}
|
||||
|
||||
val calculatedFirExpression = firExpression ?: buildErrorExpression(
|
||||
null,
|
||||
source = null,
|
||||
ConeSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax)
|
||||
)
|
||||
|
||||
return if (whenRefWithSubject != null) {
|
||||
buildEqualityOperatorCall {
|
||||
source = whenCondition.toFirSourceElement(KtFakeSourceElementKind.WhenCondition)
|
||||
operation = FirOperation.EQ
|
||||
argumentList = buildBinaryArgumentList(
|
||||
buildWhenSubjectExpression {
|
||||
whenRef = whenRefWithSubject
|
||||
}, calculatedFirExpression
|
||||
)
|
||||
}
|
||||
} else {
|
||||
calculatedFirExpression
|
||||
if (whenRefWithSubject == null) {
|
||||
return calculatedFirExpression
|
||||
}
|
||||
|
||||
return buildEqualityOperatorCall {
|
||||
source = whenCondition.toFirSourceElement(KtFakeSourceElementKind.WhenCondition)
|
||||
operation = FirOperation.EQ
|
||||
argumentList = buildBinaryArgumentList(
|
||||
left = buildWhenSubjectExpression {
|
||||
source = whenCondition.toFirSourceElement()
|
||||
whenRef = whenRefWithSubject
|
||||
},
|
||||
right = calculatedFirExpression
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -918,6 +920,7 @@ class ExpressionsConverter(
|
||||
|
||||
val subjectExpression = if (whenRefWithSubject != null) {
|
||||
buildWhenSubjectExpression {
|
||||
source = whenCondition.toFirSourceElement()
|
||||
whenRef = whenRefWithSubject
|
||||
}
|
||||
} else {
|
||||
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
// FILE: test.kt
|
||||
|
||||
fun box() {
|
||||
val a: Int? = 3
|
||||
when (a) {
|
||||
1 -> {
|
||||
1
|
||||
}
|
||||
2 -> {
|
||||
2
|
||||
}
|
||||
else -> {
|
||||
0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// EXPECTATIONS JVM JVM_IR
|
||||
// test.kt:4 box
|
||||
// test.kt:5 box
|
||||
// test.kt:6 box
|
||||
// test.kt:9 box
|
||||
// test.kt:13 box
|
||||
// test.kt:16 box
|
||||
|
||||
// EXPECTATIONS JS_IR
|
||||
// test.kt:4 box
|
||||
// test.kt:5 box
|
||||
// test.kt:5 box
|
||||
// test.kt:16 box
|
||||
+6
@@ -535,6 +535,12 @@ public class IrSteppingWithBytecodeInlinerTestGenerated extends AbstractIrSteppi
|
||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenExpr.kt")
|
||||
public void testWhenExpr() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenIsChecks.kt")
|
||||
public void testWhenIsChecks() throws Exception {
|
||||
|
||||
+6
@@ -535,6 +535,12 @@ public class IrSteppingWithIrInlinerTestGenerated extends AbstractIrSteppingWith
|
||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenExpr.kt")
|
||||
public void testWhenExpr() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenIsChecks.kt")
|
||||
public void testWhenIsChecks() throws Exception {
|
||||
|
||||
+6
@@ -535,6 +535,12 @@ public class SteppingTestGenerated extends AbstractSteppingTest {
|
||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenExpr.kt")
|
||||
public void testWhenExpr() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenIsChecks.kt")
|
||||
public void testWhenIsChecks() throws Exception {
|
||||
|
||||
+6
@@ -535,6 +535,12 @@ public class IrJsSteppingTestGenerated extends AbstractIrJsSteppingTest {
|
||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenExpr.kt")
|
||||
public void testWhenExpr() throws Exception {
|
||||
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("whenIsChecks.kt")
|
||||
public void testWhenIsChecks() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user