From 66a00f442ca30b1bf37c20f6c340b39be51b182b Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 11 Sep 2018 12:34:09 +0300 Subject: [PATCH] Add tests for obsolete issues #KT-12008 Obsolete #KT-11881 Obsolete #KT-10822 Obsolete --- .../testData/codegen/box/inference/kt10822.kt | 62 +++++++++++++++++++ .../testsWithStdLib/inference/kt12008.kt | 12 ++++ .../testsWithStdLib/inference/kt12008.txt | 12 ++++ .../testsWithStdLib/reified/kt11881.kt | 9 +++ .../testsWithStdLib/reified/kt11881.txt | 12 ++++ .../DiagnosticsTestWithStdLibGenerated.java | 10 +++ ...ticsTestWithStdLibUsingJavacGenerated.java | 10 +++ .../codegen/BlackBoxCodegenTestGenerated.java | 18 ++++++ .../LightAnalysisModeTestGenerated.java | 18 ++++++ .../ir/IrBlackBoxCodegenTestGenerated.java | 18 ++++++ .../IrJsCodegenBoxTestGenerated.java | 18 ++++++ .../semantics/JsCodegenBoxTestGenerated.java | 18 ++++++ 12 files changed, 217 insertions(+) create mode 100644 compiler/testData/codegen/box/inference/kt10822.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.txt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.txt diff --git a/compiler/testData/codegen/box/inference/kt10822.kt b/compiler/testData/codegen/box/inference/kt10822.kt new file mode 100644 index 00000000000..294644d8dff --- /dev/null +++ b/compiler/testData/codegen/box/inference/kt10822.kt @@ -0,0 +1,62 @@ +var result = "" + +interface A { + fun foo() { + result += "foo;" + } +} + +interface B : A { + fun hoo() { + result += "hoo;" + } +} + +fun doer(init: () -> T): T = init() + +class Z { + operator fun invoke(init: Z.() -> T): T = init() + infix fun doer(init: Z.() -> T): T = init() + +} + +interface ARoot { + val self : T + infix fun consume(init: T.() -> U): U = self.init() + operator fun invoke(init: T.() -> U): U = self.init() +} + +class Y : ARoot { + override val self: Y + get() = this +} + +fun box(): String { + doer { + object : B {} + }.hoo() + val z = Z() + val y = Y() + z.doer { object : B {} }.hoo() + y { + z { + object : B {} + } + }.hoo() + + y.consume { + z { + object : B {} + } + }.hoo() + + + z { + object : B {} + }.foo() + + z.doer { object : B {} }.foo() + z.doer { object : B {} }.hoo() + + return if (result == "hoo;hoo;hoo;hoo;foo;foo;hoo;") "OK" else "Fail: $result" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.kt new file mode 100644 index 00000000000..79ced2a266d --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.kt @@ -0,0 +1,12 @@ +// FULL_JDK + +import java.util.* + +fun foo(o: Optional) {} + +class Test(nullable: String?) { + private val nullableOptional = Optional.ofNullable(nullable) + fun doIt() { + foo(nullableOptional) + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.txt new file mode 100644 index 00000000000..97600847072 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.txt @@ -0,0 +1,12 @@ +package + +public fun foo(/*0*/ o: java.util.Optional): kotlin.Unit + +public final class Test { + public constructor Test(/*0*/ nullable: kotlin.String?) + private final val nullableOptional: java.util.Optional + public final fun doIt(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.kt b/compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.kt new file mode 100644 index 00000000000..39922182a14 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.kt @@ -0,0 +1,9 @@ +class Inv + +inline operator fun Inv.invoke() {} + +operator fun Inv.get(i: Int): Inv = this + +fun test(a: Inv) { + a[1]() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.txt b/compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.txt new file mode 100644 index 00000000000..f15c570ea71 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.txt @@ -0,0 +1,12 @@ +package + +public fun test(/*0*/ a: Inv): kotlin.Unit +public operator fun Inv.get(/*0*/ i: kotlin.Int): Inv +public inline operator fun Inv.invoke(): kotlin.Unit + +public final class Inv { + public constructor Inv() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 9529ddb3eff..35500e56318 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -2513,6 +2513,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.kt"); } + @TestMetadata("kt12008.kt") + public void testKt12008() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.kt"); + } + @TestMetadata("kt1558.kt") public void testKt1558() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt"); @@ -2868,6 +2873,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/reified/arrayOfNullsReified.kt"); } + @TestMetadata("kt11881.kt") + public void testKt11881() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.kt"); + } + @TestMetadata("nonCallableReiefied.kt") public void testNonCallableReiefied() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/reified/nonCallableReiefied.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index f4b6675d11e..ab41d80d7ea 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -2513,6 +2513,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt11266.kt"); } + @TestMetadata("kt12008.kt") + public void testKt12008() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt12008.kt"); + } + @TestMetadata("kt1558.kt") public void testKt1558() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/kt1558.kt"); @@ -2868,6 +2873,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/reified/arrayOfNullsReified.kt"); } + @TestMetadata("kt11881.kt") + public void testKt11881() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/reified/kt11881.kt"); + } + @TestMetadata("nonCallableReiefied.kt") public void testNonCallableReiefied() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/reified/nonCallableReiefied.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 29a2ef964c4..5928e6ebe60 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -11449,6 +11449,24 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @TestMetadata("compiler/testData/codegen/box/inference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inference extends AbstractBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInInference() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("kt10822.kt") + public void testKt10822() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt10822.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 82e60a4f708..d7b924da613 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -11449,6 +11449,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/inference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inference extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInInference() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM, true); + } + + @TestMetadata("kt10822.kt") + public void testKt10822() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt10822.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 4194e7e49ba..f1aa441d9a5 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -11449,6 +11449,24 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @TestMetadata("compiler/testData/codegen/box/inference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inference extends AbstractIrBlackBoxCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM_IR, testDataFilePath); + } + + public void testAllFilesPresentInInference() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JVM_IR, true); + } + + @TestMetadata("kt10822.kt") + public void testKt10822() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt10822.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java index e96dc407ead..6eafa5c208d 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/IrJsCodegenBoxTestGenerated.java @@ -9994,6 +9994,24 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/inference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inference extends AbstractIrJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS_IR, testDataFilePath); + } + + public void testAllFilesPresentInInference() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS_IR, true); + } + + @TestMetadata("kt10822.kt") + public void testKt10822() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt10822.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java index 2d9d249a4da..83568ec1280 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/semantics/JsCodegenBoxTestGenerated.java @@ -11059,6 +11059,24 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @TestMetadata("compiler/testData/codegen/box/inference") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Inference extends AbstractJsCodegenBoxTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.JS, testDataFilePath); + } + + public void testAllFilesPresentInInference() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/box/inference"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.JS, true); + } + + @TestMetadata("kt10822.kt") + public void testKt10822() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt10822.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/inlineClasses") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)