diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntCallSpecializedEquals.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntCallSpecializedEquals.kt new file mode 100644 index 00000000000..2d243c788c0 --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntCallSpecializedEquals.kt @@ -0,0 +1,12 @@ +// !API_VERSION: 1.3 +// WITH_RUNTIME +// FILE: test.kt +fun test() { + val result = Result.success("yes!") + val other = Result.success("nope") + if (result == other) println("==") + if (result != other) println("!=") +} + +// @TestKt.class: +// 0 INVOKESTATIC kotlin/Result.equals-impl0 diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntUseBox.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntUseBox.kt index d8065034797..d4f6293eaf3 100644 --- a/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntUseBox.kt +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntUseBox.kt @@ -1,6 +1,4 @@ -// IGNORE_BACKEND: JVM -// IGNORE_BACKEND: JVM_IR -// WITH_COROUTINES +// WITH_RUNTIME // FILE: test.kt fun test() { val result = Result.success("yes!") @@ -12,21 +10,8 @@ fun test() { println(failure.getOrNull()) println(failure.exceptionOrNull()) - val other = Result.success("nope") - if (result == other) println("==") - if (result != other) println("!=") - if (result.equals(other)) println("equals") // Boxes (JVM, JVM_IR) - if (!result.equals(other)) println("!equals") // Boxes (JVM, JVM_IR) - println(result.hashCode()) println(result.toString()) - println("$result") // Boxes (JVM_IR) - - val ans1 = runCatching { 42 } - println(ans1) // Boxes (JVM, JVM_IR) - - val ans2 = 42.runCatching { this } - println(ans2) // Boxes (JVM, JVM_IR) println(result.getOrElse { "oops" }) println(result.getOrDefault("oops")) diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiEqualsDoesntBox.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiEqualsDoesntBox.kt new file mode 100644 index 00000000000..1044928f8cb --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiEqualsDoesntBox.kt @@ -0,0 +1,14 @@ +// !API_VERSION: LATEST +// WITH_RUNTIME +// FILE: test.kt +fun test() { + val result = Result.success("yes!") + val other = Result.success("nope") + if (result == other) println("==") + if (result != other) println("!=") +} + +// @TestKt.class: +// 0 INVOKESTATIC kotlin/Result.box-impl +// 0 INVOKEVIRTUAL kotlin/Result.unbox-impl +// 2 INVOKESTATIC kotlin/Result.equals-impl0 diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiRunCatchingDoesntBox.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiRunCatchingDoesntBox.kt new file mode 100644 index 00000000000..b86baff928e --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiRunCatchingDoesntBox.kt @@ -0,0 +1,16 @@ +// IGNORE_BACKEND: JVM +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// FILE: test.kt +fun test() { + val ans1 = runCatching { 42 } + println(ans1) + + val ans2 = 42.runCatching { this } + println(ans2) +} + +// @TestKt.class: +// 0 INVOKESTATIC kotlin/Result.box-impl +// 0 INVOKEVIRTUAL kotlin/Result.unbox-impl +// 0 Result\$Failure diff --git a/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiStringInterpolationDoesntBox.kt b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiStringInterpolationDoesntBox.kt new file mode 100644 index 00000000000..f43dfb8c4ce --- /dev/null +++ b/compiler/testData/codegen/bytecodeText/inlineClasses/resultApiStringInterpolationDoesntBox.kt @@ -0,0 +1,11 @@ +// IGNORE_BACKEND: JVM_IR +// WITH_RUNTIME +// FILE: test.kt +fun test() { + val result = Result.success("yes!") + println("$result") +} + +// @TestKt.class: +// 0 INVOKESTATIC kotlin/Result.box-impl +// 0 INVOKEVIRTUAL kotlin/Result.unbox-impl diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java index aedff5504a7..5ab24da7713 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BytecodeTextTestGenerated.java @@ -2603,11 +2603,31 @@ public class BytecodeTextTestGenerated extends AbstractBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/propertySetterWithInlineClassTypeArgument.kt"); } + @TestMetadata("resultApiDoesntCallSpecializedEquals.kt") + public void testResultApiDoesntCallSpecializedEquals() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntCallSpecializedEquals.kt"); + } + @TestMetadata("resultApiDoesntUseBox.kt") public void testResultApiDoesntUseBox() throws Exception { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntUseBox.kt"); } + @TestMetadata("resultApiEqualsDoesntBox.kt") + public void testResultApiEqualsDoesntBox() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiEqualsDoesntBox.kt"); + } + + @TestMetadata("resultApiRunCatchingDoesntBox.kt") + public void testResultApiRunCatchingDoesntBox() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiRunCatchingDoesntBox.kt"); + } + + @TestMetadata("resultApiStringInterpolationDoesntBox.kt") + public void testResultApiStringInterpolationDoesntBox() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiStringInterpolationDoesntBox.kt"); + } + @TestMetadata("resultMangling.kt") public void testResultMangling() throws Exception { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultMangling.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java index ff6fae38a70..77cc3f96811 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBytecodeTextTestGenerated.java @@ -2573,11 +2573,31 @@ public class IrBytecodeTextTestGenerated extends AbstractIrBytecodeTextTest { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/propertySetterWithInlineClassTypeArgument.kt"); } + @TestMetadata("resultApiDoesntCallSpecializedEquals.kt") + public void testResultApiDoesntCallSpecializedEquals() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntCallSpecializedEquals.kt"); + } + @TestMetadata("resultApiDoesntUseBox.kt") public void testResultApiDoesntUseBox() throws Exception { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiDoesntUseBox.kt"); } + @TestMetadata("resultApiEqualsDoesntBox.kt") + public void testResultApiEqualsDoesntBox() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiEqualsDoesntBox.kt"); + } + + @TestMetadata("resultApiRunCatchingDoesntBox.kt") + public void testResultApiRunCatchingDoesntBox() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiRunCatchingDoesntBox.kt"); + } + + @TestMetadata("resultApiStringInterpolationDoesntBox.kt") + public void testResultApiStringInterpolationDoesntBox() throws Exception { + runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultApiStringInterpolationDoesntBox.kt"); + } + @TestMetadata("resultMangling.kt") public void testResultMangling() throws Exception { runTest("compiler/testData/codegen/bytecodeText/inlineClasses/resultMangling.kt");