From f7ce8c18c699cd78e082e9bcb0639d8edd6e44f2 Mon Sep 17 00:00:00 2001 From: Mikhael Bogdanov Date: Tue, 8 Jan 2019 15:43:17 +0100 Subject: [PATCH] Add tests for Obsolete issues #KT-18977 Obsolete --- .../boxInline/anonymousObject/kt15751.kt | 3 +++ .../boxInline/callableReference/kt15751_2.kt | 4 +++ .../nonLocalReturns/tryFinally/kt16417.kt | 5 ++++ .../codegen/boxInline/reified/kt18977.kt | 26 +++++++++++++++++++ .../BlackBoxInlineCodegenTestGenerated.java | 5 ++++ ...otlinAgainstInlineKotlinTestGenerated.java | 5 ++++ .../IrBlackBoxInlineCodegenTestGenerated.java | 5 ++++ 7 files changed, 53 insertions(+) create mode 100644 compiler/testData/codegen/boxInline/reified/kt18977.kt diff --git a/compiler/testData/codegen/boxInline/anonymousObject/kt15751.kt b/compiler/testData/codegen/boxInline/anonymousObject/kt15751.kt index aaff8f1fe30..be971af9fd7 100644 --- a/compiler/testData/codegen/boxInline/anonymousObject/kt15751.kt +++ b/compiler/testData/codegen/boxInline/anonymousObject/kt15751.kt @@ -1,5 +1,7 @@ // FILE: 1.kt // NO_CHECK_LAMBDA_INLINING +package test + class A { val foo = fun(call: () -> Unit) = ext { @@ -24,6 +26,7 @@ class A { } // FILE: 2.kt +import test.* fun box(): String { var result = "fail" diff --git a/compiler/testData/codegen/boxInline/callableReference/kt15751_2.kt b/compiler/testData/codegen/boxInline/callableReference/kt15751_2.kt index b2fac901b2b..285f14aac53 100644 --- a/compiler/testData/codegen/boxInline/callableReference/kt15751_2.kt +++ b/compiler/testData/codegen/boxInline/callableReference/kt15751_2.kt @@ -1,6 +1,8 @@ // FILE: 1.kt // IGNORE_BACKEND: JS // WITH_RUNTIME +package test + public inline fun T.myalso(block: (T) -> Unit): T { block(this) return this @@ -12,6 +14,8 @@ public inline fun Iterable.mymapNotNull(transform: (T) -> R?): L // FILE: 2.kt // NO_CHECK_LAMBDA_INLINING +import test.* + var result = -1; fun box(): String { diff --git a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt16417.kt b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt16417.kt index 085b01c653f..d09cef201b1 100644 --- a/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt16417.kt +++ b/compiler/testData/codegen/boxInline/nonLocalReturns/tryFinally/kt16417.kt @@ -1,5 +1,7 @@ // IGNORE_BACKEND: JVM_IR // FILE: 1.kt +package test + class A { var field = 0 @@ -28,6 +30,9 @@ class A { // FILE: 2.kt // NO_CHECK_LAMBDA_INLINING + +import test.* + fun box(): String { val a = A() a.c ({ "OK" }) diff --git a/compiler/testData/codegen/boxInline/reified/kt18977.kt b/compiler/testData/codegen/boxInline/reified/kt18977.kt new file mode 100644 index 00000000000..11068f27dde --- /dev/null +++ b/compiler/testData/codegen/boxInline/reified/kt18977.kt @@ -0,0 +1,26 @@ +// FILE: 1.kt +package test + +class AbstractTreeNode(val value: T, val parent: AbstractTreeNode?) + +internal inline fun AbstractTreeNode<*>.findNotNullValueOfType(strict: Boolean = false): T { + return findValueOfType(strict)!! +} + +internal inline fun AbstractTreeNode<*>.findValueOfType(strict: Boolean = true): T? { + var current: AbstractTreeNode<*>? = if (strict) this.parent else this + while (current != null) { + val value = current.value + if (value is T) return value + current = current.parent + } + return null +} + +// FILE: 2.kt + +import test.* + +fun box(): String { + return AbstractTreeNode("OK", null).findNotNullValueOfType()!! +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java index 9c4df180af9..76133edb41f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxInlineCodegenTestGenerated.java @@ -2578,6 +2578,11 @@ public class BlackBoxInlineCodegenTestGenerated extends AbstractBlackBoxInlineCo runTest("compiler/testData/codegen/boxInline/reified/kt15997_2.kt"); } + @TestMetadata("kt18977.kt") + public void testKt18977() throws Exception { + runTest("compiler/testData/codegen/boxInline/reified/kt18977.kt"); + } + @TestMetadata("kt6988.kt") public void testKt6988() throws Exception { runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java index 53681dff831..2b78cff1ea8 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CompileKotlinAgainstInlineKotlinTestGenerated.java @@ -2578,6 +2578,11 @@ public class CompileKotlinAgainstInlineKotlinTestGenerated extends AbstractCompi runTest("compiler/testData/codegen/boxInline/reified/kt15997_2.kt"); } + @TestMetadata("kt18977.kt") + public void testKt18977() throws Exception { + runTest("compiler/testData/codegen/boxInline/reified/kt18977.kt"); + } + @TestMetadata("kt6988.kt") public void testKt6988() throws Exception { runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java index a7fc65ec2bd..7973e3909e3 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxInlineCodegenTestGenerated.java @@ -2578,6 +2578,11 @@ public class IrBlackBoxInlineCodegenTestGenerated extends AbstractIrBlackBoxInli runTest("compiler/testData/codegen/boxInline/reified/kt15997_2.kt"); } + @TestMetadata("kt18977.kt") + public void testKt18977() throws Exception { + runTest("compiler/testData/codegen/boxInline/reified/kt18977.kt"); + } + @TestMetadata("kt6988.kt") public void testKt6988() throws Exception { runTest("compiler/testData/codegen/boxInline/reified/kt6988.kt");