From d59b910403ef8c488a4a0d1788d796f3427fa288 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Thu, 15 Aug 2019 10:58:38 +0300 Subject: [PATCH] Add tests for obsolete issues #KT-32207 Obsolete #KT-32836 Obsolete #KT-32949 Obsolete #KT-9384 Obsolete --- .../fir/FirDiagnosticsSmokeTestGenerated.java | 15 ++++++++ .../codegen/box/regressions/kt32949.kt | 34 +++++++++++++++++++ .../tests/inference/nothingType/kt32207.kt | 15 ++++++++ .../tests/inference/nothingType/kt32207.txt | 21 ++++++++++++ .../diagnostics/tests/regressions/kt32836.kt | 17 ++++++++++ .../diagnostics/tests/regressions/kt32836.txt | 12 +++++++ .../diagnostics/tests/regressions/kt9384.kt | 11 ++++++ .../diagnostics/tests/regressions/kt9384.txt | 3 ++ .../checkers/DiagnosticsTestGenerated.java | 15 ++++++++ .../DiagnosticsUsingJavacTestGenerated.java | 15 ++++++++ .../codegen/BlackBoxCodegenTestGenerated.java | 5 +++ .../LightAnalysisModeTestGenerated.java | 5 +++ .../ir/IrBlackBoxCodegenTestGenerated.java | 5 +++ .../IrJsCodegenBoxTestGenerated.java | 5 +++ .../semantics/JsCodegenBoxTestGenerated.java | 5 +++ 15 files changed, 183 insertions(+) create mode 100644 compiler/testData/codegen/box/regressions/kt32949.kt create mode 100644 compiler/testData/diagnostics/tests/inference/nothingType/kt32207.kt create mode 100644 compiler/testData/diagnostics/tests/inference/nothingType/kt32207.txt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt32836.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt32836.txt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt9384.kt create mode 100644 compiler/testData/diagnostics/tests/regressions/kt9384.txt diff --git a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java index 26d37186128..f40c7e45516 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -10363,6 +10363,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32081.kt"); } + @TestMetadata("kt32207.kt") + public void testKt32207() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32207.kt"); + } + @TestMetadata("kt32388.kt") public void testKt32388() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt"); @@ -17105,6 +17110,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/regressions/kt328.kt"); } + @TestMetadata("kt32836.kt") + public void testKt32836() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt32836.kt"); + } + @TestMetadata("kt334.kt") public void testKt334() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt334.kt"); @@ -17375,6 +17385,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/regressions/kt860.kt"); } + @TestMetadata("kt9384.kt") + public void testKt9384() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt9384.kt"); + } + @TestMetadata("kt9620.kt") public void testKt9620() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt9620.kt"); diff --git a/compiler/testData/codegen/box/regressions/kt32949.kt b/compiler/testData/codegen/box/regressions/kt32949.kt new file mode 100644 index 00000000000..aa36bd2b87c --- /dev/null +++ b/compiler/testData/codegen/box/regressions/kt32949.kt @@ -0,0 +1,34 @@ +class Binder() { + lateinit var bindee: Container<*> + + fun bind(subject: Container<*>): String { + bindee = subject + return when(subject.containee) { + is Foo -> bind(subject.containee) + is Bar -> bind(subject.containee) + else -> TODO() + } + } + + private fun bind(foo: Foo): String { + return "binding $foo" + } + private fun bind(bar: Bar): String { + return "binding $bar" + } +} +class Container(val containee: T) +data class Foo(val x: Int = 0) +data class Bar(val y: Int = 0) + +fun box(): String { + val f = Container(Foo(1)) + val b = Container(Bar(2)) + + val binder = Binder() + + if (binder.bind(f) != "binding Foo(x=1)") return "fail 1" + if (binder.bind(b) != "binding Bar(y=2)") return "fail 2" + + return "OK" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/kt32207.kt b/compiler/testData/diagnostics/tests/inference/nothingType/kt32207.kt new file mode 100644 index 00000000000..aff2fa3512d --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/nothingType/kt32207.kt @@ -0,0 +1,15 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +class Test { + fun hereIdeaFail(values : List, others : List): List> { + return values.map { left(it) }.plus(others.map { right(it) }) + } + + companion object { + fun left(left: L): Test = TODO() + fun right(right: R): Test = TODO() + } +} + +fun Iterable.map(transform: (T) -> R): List = TODO() +operator fun Collection.plus(elements: Iterable): List = TODO() diff --git a/compiler/testData/diagnostics/tests/inference/nothingType/kt32207.txt b/compiler/testData/diagnostics/tests/inference/nothingType/kt32207.txt new file mode 100644 index 00000000000..79f7b74e146 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/nothingType/kt32207.txt @@ -0,0 +1,21 @@ +package + +public fun kotlin.collections.Iterable.map(/*0*/ transform: (T) -> R): kotlin.collections.List +public operator fun kotlin.collections.Collection.plus(/*0*/ elements: kotlin.collections.Iterable): kotlin.collections.List + +public final class Test { + public constructor Test() + 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 final fun hereIdeaFail(/*0*/ values: kotlin.collections.List, /*1*/ others: kotlin.collections.List): kotlin.collections.List> + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion { + private constructor Companion() + 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 final fun left(/*0*/ left: L): Test + public final fun right(/*0*/ right: R): Test + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/regressions/kt32836.kt b/compiler/testData/diagnostics/tests/regressions/kt32836.kt new file mode 100644 index 00000000000..adbdda52fea --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt32836.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +inline fun parse(json: String): T? = TODO() + +class MyType + +fun parseMyData(json: String): MyType = + try { + parse(json) // error with new inf only: Cannot use 'Nothing?' as reified type parameter + ?: throw IllegalArgumentException("Can't parse") + } catch (e: Exception) { + throw IllegalArgumentException("Can't parse") + } + +fun main() { + parseMyData("") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt32836.txt b/compiler/testData/diagnostics/tests/regressions/kt32836.txt new file mode 100644 index 00000000000..dc9ecf2b95e --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt32836.txt @@ -0,0 +1,12 @@ +package + +public fun main(): kotlin.Unit +public inline fun parse(/*0*/ json: kotlin.String): T? +public fun parseMyData(/*0*/ json: kotlin.String): MyType + +public final class MyType { + public constructor MyType() + 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/tests/regressions/kt9384.kt b/compiler/testData/diagnostics/tests/regressions/kt9384.kt new file mode 100644 index 00000000000..b2258e5158e --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt9384.kt @@ -0,0 +1,11 @@ +fun main(args: Array) { + fun f() = run { + private class C { + private fun foo() { + f().foo(); + + } + } + C() + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt9384.txt b/compiler/testData/diagnostics/tests/regressions/kt9384.txt new file mode 100644 index 00000000000..49ba831837b --- /dev/null +++ b/compiler/testData/diagnostics/tests/regressions/kt9384.txt @@ -0,0 +1,3 @@ +package + +public fun main(/*0*/ args: kotlin.Array): kotlin.Unit diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 73181bd82fb..ee656f75e4d 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -10370,6 +10370,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32081.kt"); } + @TestMetadata("kt32207.kt") + public void testKt32207() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32207.kt"); + } + @TestMetadata("kt32388.kt") public void testKt32388() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt"); @@ -17117,6 +17122,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/regressions/kt328.kt"); } + @TestMetadata("kt32836.kt") + public void testKt32836() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt32836.kt"); + } + @TestMetadata("kt334.kt") public void testKt334() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt334.kt"); @@ -17387,6 +17397,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/regressions/kt860.kt"); } + @TestMetadata("kt9384.kt") + public void testKt9384() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt9384.kt"); + } + @TestMetadata("kt9620.kt") public void testKt9620() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt9620.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 79ef04507dd..afce997591a 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -10365,6 +10365,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32081.kt"); } + @TestMetadata("kt32207.kt") + public void testKt32207() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32207.kt"); + } + @TestMetadata("kt32388.kt") public void testKt32388() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/nothingType/kt32388.kt"); @@ -17107,6 +17112,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/regressions/kt328.kt"); } + @TestMetadata("kt32836.kt") + public void testKt32836() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt32836.kt"); + } + @TestMetadata("kt334.kt") public void testKt334() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt334.kt"); @@ -17377,6 +17387,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/regressions/kt860.kt"); } + @TestMetadata("kt9384.kt") + public void testKt9384() throws Exception { + runTest("compiler/testData/diagnostics/tests/regressions/kt9384.kt"); + } + @TestMetadata("kt9620.kt") public void testKt9620() throws Exception { runTest("compiler/testData/diagnostics/tests/regressions/kt9620.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 5cd5f680f7a..5010b551261 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -22819,6 +22819,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/regressions/kt3107.kt"); } + @TestMetadata("kt32949.kt") + public void testKt32949() throws Exception { + runTest("compiler/testData/codegen/box/regressions/kt32949.kt"); + } + @TestMetadata("kt3421.kt") public void testKt3421() throws Exception { runTest("compiler/testData/codegen/box/regressions/kt3421.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 1897dcbb8eb..2ae341cfb31 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -22819,6 +22819,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/regressions/kt3107.kt"); } + @TestMetadata("kt32949.kt") + public void testKt32949() throws Exception { + runTest("compiler/testData/codegen/box/regressions/kt32949.kt"); + } + @TestMetadata("kt3421.kt") public void testKt3421() throws Exception { runTest("compiler/testData/codegen/box/regressions/kt3421.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index cafeb5432ca..9dcf2c3c5f7 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -21719,6 +21719,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/regressions/kt3107.kt"); } + @TestMetadata("kt32949.kt") + public void testKt32949() throws Exception { + runTest("compiler/testData/codegen/box/regressions/kt32949.kt"); + } + @TestMetadata("kt3421.kt") public void testKt3421() throws Exception { runTest("compiler/testData/codegen/box/regressions/kt3421.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java index 12e1e47fc42..1fd598bd052 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/ir/semantics/IrJsCodegenBoxTestGenerated.java @@ -17484,6 +17484,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/regressions/kt3107.kt"); } + @TestMetadata("kt32949.kt") + public void testKt32949() throws Exception { + runTest("compiler/testData/codegen/box/regressions/kt32949.kt"); + } + @TestMetadata("kt3421.kt") public void testKt3421() throws Exception { runTest("compiler/testData/codegen/box/regressions/kt3421.kt"); 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 3562080a77f..f31ef3d3270 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 @@ -18639,6 +18639,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/regressions/kt3107.kt"); } + @TestMetadata("kt32949.kt") + public void testKt32949() throws Exception { + runTest("compiler/testData/codegen/box/regressions/kt32949.kt"); + } + @TestMetadata("kt3421.kt") public void testKt3421() throws Exception { runTest("compiler/testData/codegen/box/regressions/kt3421.kt");