Generate line numbers for RHS of elvis expression if both LHS and RHS
are at the same line. #KT-32689 Fixed
This commit is contained in:
@@ -3809,6 +3809,11 @@ public class ExpressionCodegen extends KtVisitor<StackValue, StackValue> impleme
|
|||||||
v.goTo(end);
|
v.goTo(end);
|
||||||
|
|
||||||
v.mark(ifNull);
|
v.mark(ifNull);
|
||||||
|
Integer leftLineNumber = CodegenUtil.getLineNumberForElement(left, false);
|
||||||
|
Integer rightLineNumber = CodegenUtil.getLineNumberForElement(expression.getRight(), false);
|
||||||
|
if (rightLineNumber != null && rightLineNumber.equals(leftLineNumber)) {
|
||||||
|
v.visitLineNumber(rightLineNumber, ifNull);
|
||||||
|
}
|
||||||
v.pop();
|
v.pop();
|
||||||
gen(expression.getRight(), exprType, exprKotlinType);
|
gen(expression.getRight(), exprType, exprKotlinType);
|
||||||
v.mark(end);
|
v.mark(end);
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
// IGNORE_BACKEND: JVM_IR
|
||||||
|
// TARGET_BACKEND: JVM
|
||||||
|
// WITH_RUNTIME
|
||||||
|
// WITH_COROUTINES
|
||||||
|
// FULL_JDK
|
||||||
|
|
||||||
|
import helpers.*
|
||||||
|
import kotlin.coroutines.*
|
||||||
|
import kotlin.coroutines.intrinsics.*
|
||||||
|
|
||||||
|
fun builder(c: suspend () -> Unit) {
|
||||||
|
c.startCoroutine(EmptyContinuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun returnsNull() = null
|
||||||
|
|
||||||
|
fun withLineBreak() = builder {
|
||||||
|
returnsNull()
|
||||||
|
?: throw RuntimeException()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun withoutLineBreak() = builder {
|
||||||
|
returnsNull() ?: throw RuntimeException()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
try {
|
||||||
|
withLineBreak()
|
||||||
|
return "FAIL 0"
|
||||||
|
} catch (e: RuntimeException) {
|
||||||
|
if (e.stackTrace[0].lineNumber != 19) return "FAIL 1 ${e.stackTrace[0].lineNumber}"
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
withoutLineBreak()
|
||||||
|
return "FAIL 2"
|
||||||
|
} catch (e: RuntimeException) {
|
||||||
|
if (e.stackTrace[0].lineNumber != 23) return "FAIL 3 ${e.stackTrace[0].lineNumber}"
|
||||||
|
}
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+5
@@ -6790,6 +6790,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata.kt");
|
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("elvisLineNumber.kt")
|
||||||
|
public void testElvisLineNumber() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/debug/elvisLineNumber.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("firstSuspensionPoint.kt")
|
@TestMetadata("firstSuspensionPoint.kt")
|
||||||
public void testFirstSuspensionPoint() throws Exception {
|
public void testFirstSuspensionPoint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
|
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
|
||||||
|
|||||||
+5
@@ -6790,6 +6790,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata.kt");
|
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("elvisLineNumber.kt")
|
||||||
|
public void testElvisLineNumber() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/debug/elvisLineNumber.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("firstSuspensionPoint.kt")
|
@TestMetadata("firstSuspensionPoint.kt")
|
||||||
public void testFirstSuspensionPoint() throws Exception {
|
public void testFirstSuspensionPoint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
|
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
|
||||||
|
|||||||
+5
@@ -6245,6 +6245,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes
|
|||||||
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata.kt");
|
runTest("compiler/testData/codegen/box/coroutines/debug/debuggerMetadata.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("elvisLineNumber.kt")
|
||||||
|
public void testElvisLineNumber() throws Exception {
|
||||||
|
runTest("compiler/testData/codegen/box/coroutines/debug/elvisLineNumber.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("firstSuspensionPoint.kt")
|
@TestMetadata("firstSuspensionPoint.kt")
|
||||||
public void testFirstSuspensionPoint() throws Exception {
|
public void testFirstSuspensionPoint() throws Exception {
|
||||||
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
|
runTest("compiler/testData/codegen/box/coroutines/debug/firstSuspensionPoint.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user