[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");
|
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whenExpr.kt")
|
||||||
|
public void testWhenExpr() throws Exception {
|
||||||
|
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("whenIsChecks.kt")
|
@TestMetadata("whenIsChecks.kt")
|
||||||
public void testWhenIsChecks() throws Exception {
|
public void testWhenIsChecks() throws Exception {
|
||||||
|
|||||||
+6
@@ -535,6 +535,12 @@ public class FirPsiSteppingTestGenerated extends AbstractFirPsiSteppingTest {
|
|||||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whenExpr.kt")
|
||||||
|
public void testWhenExpr() throws Exception {
|
||||||
|
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("whenIsChecks.kt")
|
@TestMetadata("whenIsChecks.kt")
|
||||||
public void testWhenIsChecks() throws Exception {
|
public void testWhenIsChecks() throws Exception {
|
||||||
|
|||||||
+16
-13
@@ -835,22 +835,24 @@ class ExpressionsConverter(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val calculatedFirExpression = firExpression ?: buildErrorExpression(
|
val calculatedFirExpression = firExpression ?: buildErrorExpression(
|
||||||
null,
|
source = null,
|
||||||
ConeSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax)
|
ConeSimpleDiagnostic("No expression in condition with expression", DiagnosticKind.Syntax)
|
||||||
)
|
)
|
||||||
|
|
||||||
return if (whenRefWithSubject != null) {
|
if (whenRefWithSubject == null) {
|
||||||
buildEqualityOperatorCall {
|
return calculatedFirExpression
|
||||||
source = whenCondition.toFirSourceElement(KtFakeSourceElementKind.WhenCondition)
|
}
|
||||||
operation = FirOperation.EQ
|
|
||||||
argumentList = buildBinaryArgumentList(
|
return buildEqualityOperatorCall {
|
||||||
buildWhenSubjectExpression {
|
source = whenCondition.toFirSourceElement(KtFakeSourceElementKind.WhenCondition)
|
||||||
whenRef = whenRefWithSubject
|
operation = FirOperation.EQ
|
||||||
}, calculatedFirExpression
|
argumentList = buildBinaryArgumentList(
|
||||||
)
|
left = buildWhenSubjectExpression {
|
||||||
}
|
source = whenCondition.toFirSourceElement()
|
||||||
} else {
|
whenRef = whenRefWithSubject
|
||||||
calculatedFirExpression
|
},
|
||||||
|
right = calculatedFirExpression
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -918,6 +920,7 @@ class ExpressionsConverter(
|
|||||||
|
|
||||||
val subjectExpression = if (whenRefWithSubject != null) {
|
val subjectExpression = if (whenRefWithSubject != null) {
|
||||||
buildWhenSubjectExpression {
|
buildWhenSubjectExpression {
|
||||||
|
source = whenCondition.toFirSourceElement()
|
||||||
whenRef = whenRefWithSubject
|
whenRef = whenRefWithSubject
|
||||||
}
|
}
|
||||||
} else {
|
} 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");
|
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whenExpr.kt")
|
||||||
|
public void testWhenExpr() throws Exception {
|
||||||
|
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("whenIsChecks.kt")
|
@TestMetadata("whenIsChecks.kt")
|
||||||
public void testWhenIsChecks() throws Exception {
|
public void testWhenIsChecks() throws Exception {
|
||||||
|
|||||||
+6
@@ -535,6 +535,12 @@ public class IrSteppingWithIrInlinerTestGenerated extends AbstractIrSteppingWith
|
|||||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whenExpr.kt")
|
||||||
|
public void testWhenExpr() throws Exception {
|
||||||
|
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("whenIsChecks.kt")
|
@TestMetadata("whenIsChecks.kt")
|
||||||
public void testWhenIsChecks() throws Exception {
|
public void testWhenIsChecks() throws Exception {
|
||||||
|
|||||||
+6
@@ -535,6 +535,12 @@ public class SteppingTestGenerated extends AbstractSteppingTest {
|
|||||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whenExpr.kt")
|
||||||
|
public void testWhenExpr() throws Exception {
|
||||||
|
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("whenIsChecks.kt")
|
@TestMetadata("whenIsChecks.kt")
|
||||||
public void testWhenIsChecks() throws Exception {
|
public void testWhenIsChecks() throws Exception {
|
||||||
|
|||||||
+6
@@ -535,6 +535,12 @@ public class IrJsSteppingTestGenerated extends AbstractIrJsSteppingTest {
|
|||||||
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
runTest("compiler/testData/debug/stepping/whenConstant.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("whenExpr.kt")
|
||||||
|
public void testWhenExpr() throws Exception {
|
||||||
|
runTest("compiler/testData/debug/stepping/whenExpr.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("whenIsChecks.kt")
|
@TestMetadata("whenIsChecks.kt")
|
||||||
public void testWhenIsChecks() throws Exception {
|
public void testWhenIsChecks() throws Exception {
|
||||||
|
|||||||
Reference in New Issue
Block a user