From 7850d5fbde2dfe7572c92d1658cee54df9496d8a Mon Sep 17 00:00:00 2001 From: sergeych Date: Mon, 9 Feb 2026 10:07:32 +0300 Subject: [PATCH] Cover optional index pre-inc short-circuit --- .../src/commonTest/kotlin/BytecodeRecentOpsTest.kt | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lynglib/src/commonTest/kotlin/BytecodeRecentOpsTest.kt b/lynglib/src/commonTest/kotlin/BytecodeRecentOpsTest.kt index 529d455..d14052d 100644 --- a/lynglib/src/commonTest/kotlin/BytecodeRecentOpsTest.kt +++ b/lynglib/src/commonTest/kotlin/BytecodeRecentOpsTest.kt @@ -115,6 +115,20 @@ class BytecodeRecentOpsTest { ) } + @Test + fun optionalIndexPreIncSkipsOnNullReceiver() = runTest { + eval( + """ + var count = 0 + fun idx() { count = count + 1; return 1 } + var a: List? = null + val r = ++a?[idx()] + assertEquals(null, r) + assertEquals(0, count) + """.trimIndent() + ) + } + @Test fun optionalClassScopeIncDec() = runTest { eval(