From 684ca5029f0eb1ba6df167edad8bd820c6b02765 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Fri, 26 Jun 2020 06:24:59 +0300 Subject: [PATCH] Add tests for obsolete issues #KT-37734 Obsolete #KT-39824 Obsolete --- ...endDiagnosticsTestWithStdlibGenerated.java | 5 +++ .../ir/FirBlackBoxCodegenTestGenerated.java | 5 +++ .../testData/codegen/box/inference/kt39824.kt | 33 +++++++++++++++++++ ...tAnnotationWithUpperBoundConstraint.fir.kt | 17 ++++++++++ ...exactAnnotationWithUpperBoundConstraint.kt | 17 ++++++++++ ...xactAnnotationWithUpperBoundConstraint.txt | 4 +++ .../DiagnosticsTestWithStdLibGenerated.java | 5 +++ ...ticsTestWithStdLibUsingJavacGenerated.java | 5 +++ .../codegen/BlackBoxCodegenTestGenerated.java | 5 +++ .../LightAnalysisModeTestGenerated.java | 5 +++ .../ir/IrBlackBoxCodegenTestGenerated.java | 5 +++ .../IrJsCodegenBoxES6TestGenerated.java | 5 +++ .../IrJsCodegenBoxTestGenerated.java | 5 +++ .../semantics/JsCodegenBoxTestGenerated.java | 5 +++ 14 files changed, 121 insertions(+) create mode 100644 compiler/testData/codegen/box/inference/kt39824.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.kt create mode 100644 compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.txt diff --git a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java index eeb9de10902..97e8cf86bef 100644 --- a/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java +++ b/compiler/fir/analysis-tests/tests/org/jetbrains/kotlin/fir/FirOldFrontendDiagnosticsTestWithStdlibGenerated.java @@ -2072,6 +2072,11 @@ public class FirOldFrontendDiagnosticsTestWithStdlibGenerated extends AbstractFi runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt"); } + @TestMetadata("exactAnnotationWithUpperBoundConstraint.kt") + public void testExactAnnotationWithUpperBoundConstraint() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.kt"); + } + @TestMetadata("explicitTypeArgumentAsValidInputType.kt") public void testExplicitTypeArgumentAsValidInputType() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.kt"); diff --git a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java index 34f126eaad7..418c8abea5a 100644 --- a/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests/org/jetbrains/kotlin/codegen/ir/FirBlackBoxCodegenTestGenerated.java @@ -12414,6 +12414,11 @@ public class FirBlackBoxCodegenTestGenerated extends AbstractFirBlackBoxCodegenT runTest("compiler/testData/codegen/box/inference/kt36446.kt"); } + @TestMetadata("kt39824.kt") + public void testKt39824() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt39824.kt"); + } + @TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt") public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception { runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt"); diff --git a/compiler/testData/codegen/box/inference/kt39824.kt b/compiler/testData/codegen/box/inference/kt39824.kt new file mode 100644 index 00000000000..04f88e04615 --- /dev/null +++ b/compiler/testData/codegen/box/inference/kt39824.kt @@ -0,0 +1,33 @@ +// WITH_RUNTIME + +fun diContext(context: C): DIContext = DIContext(TypeToken(), context) +fun diContext(getContext: () -> C): DIContext = DIContext(TypeToken()) { getContext() } + +interface DIContext { + val type: TypeToken + val value: C + + fun print() { + result += value.toString() + } + + data class Value(override val type: TypeToken, override val value: C) : DIContext + class Lazy(override val type: TypeToken, public val getValue: () -> C) : DIContext { + override val value: C by lazy(getValue) + } + + companion object { + operator fun invoke(type: TypeToken, value: C): DIContext = Value(type, value) + operator fun invoke(type: TypeToken, getValue: () -> C): DIContext = Lazy(type, getValue) + } +} + +class TypeToken + +var result = "" + +fun box(): String { + diContext("O").print() + diContext { "K" }.print() + return result +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt new file mode 100644 index 00000000000..3b9dab21dfb --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.fir.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?> + Map.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO() + +fun test() { + val map: Map = mapOf("x" to 1) + + val r1 = map.getOrDefault_Exact("y", null) + r1 + + val r2 = map.getOrDefault_Exact("y", null as Int?) + r2 + + map.getOrDefault_Exact("y", "string") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.kt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.kt new file mode 100644 index 00000000000..3a37dabbd40 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.kt @@ -0,0 +1,17 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER -DEBUG_INFO_CONSTANT -UNUSED_EXPRESSION + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun <@kotlin.internal.OnlyInputTypes K, V, V1 : V?> + Map.getOrDefault_Exact(key: K, defaultValue: V1): V1 = TODO() + +fun test() { + val map: Map = mapOf("x" to 1) + + val r1 = map.getOrDefault_Exact("y", null) + r1 + + val r2 = map.getOrDefault_Exact("y", null as Int?) + r2 + + map.getOrDefault_Exact("y", "string") +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.txt b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.txt new file mode 100644 index 00000000000..3a5920e2492 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.txt @@ -0,0 +1,4 @@ +package + +public fun test(): kotlin.Unit +@kotlin.Suppress(names = {"INVISIBLE_MEMBER", "INVISIBLE_REFERENCE"}) public fun kotlin.collections.Map.getOrDefault_Exact(/*0*/ key: K, /*1*/ defaultValue: V1): V1 diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java index 84dac9551e2..560ef787a33 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java @@ -3102,6 +3102,11 @@ public class DiagnosticsTestWithStdLibGenerated extends AbstractDiagnosticsTestW runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt"); } + @TestMetadata("exactAnnotationWithUpperBoundConstraint.kt") + public void testExactAnnotationWithUpperBoundConstraint() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.kt"); + } + @TestMetadata("explicitTypeArgumentAsValidInputType.kt") public void testExplicitTypeArgumentAsValidInputType() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java index 7c4cb994745..d3d0ccfefc4 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java @@ -3102,6 +3102,11 @@ public class DiagnosticsTestWithStdLibUsingJavacGenerated extends AbstractDiagno runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotation.kt"); } + @TestMetadata("exactAnnotationWithUpperBoundConstraint.kt") + public void testExactAnnotationWithUpperBoundConstraint() throws Exception { + runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/exactAnnotationWithUpperBoundConstraint.kt"); + } + @TestMetadata("explicitTypeArgumentAsValidInputType.kt") public void testExplicitTypeArgumentAsValidInputType() throws Exception { runTest("compiler/testData/diagnostics/testsWithStdLib/inference/annotationsForResolve/explicitTypeArgumentAsValidInputType.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java index 162d398c1dd..46c97c867b3 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/BlackBoxCodegenTestGenerated.java @@ -13639,6 +13639,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { runTest("compiler/testData/codegen/box/inference/kt36446.kt"); } + @TestMetadata("kt39824.kt") + public void testKt39824() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt39824.kt"); + } + @TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt") public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception { runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3bb7fe65ed5..4b52cedb8d8 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -13639,6 +13639,11 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes runTest("compiler/testData/codegen/box/inference/kt36446.kt"); } + @TestMetadata("kt39824.kt") + public void testKt39824() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt39824.kt"); + } + @TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt") public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception { runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java index 603c5073891..b50ad865aec 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/ir/IrBlackBoxCodegenTestGenerated.java @@ -12414,6 +12414,11 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes runTest("compiler/testData/codegen/box/inference/kt36446.kt"); } + @TestMetadata("kt39824.kt") + public void testKt39824() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt39824.kt"); + } + @TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt") public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception { runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt"); diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java index 32869dacc41..edf8cf33eea 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/es6/semantics/IrJsCodegenBoxES6TestGenerated.java @@ -10679,6 +10679,11 @@ public class IrJsCodegenBoxES6TestGenerated extends AbstractIrJsCodegenBoxES6Tes runTest("compiler/testData/codegen/box/inference/kt36446.kt"); } + @TestMetadata("kt39824.kt") + public void testKt39824() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt39824.kt"); + } + @TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt") public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception { runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.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 f3a9fc09301..cb7b12805c7 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 @@ -10689,6 +10689,11 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inference/kt36446.kt"); } + @TestMetadata("kt39824.kt") + public void testKt39824() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt39824.kt"); + } + @TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt") public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception { runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.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 a58d161ffd5..6997f7fa23e 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 @@ -10754,6 +10754,11 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { runTest("compiler/testData/codegen/box/inference/kt36446.kt"); } + @TestMetadata("kt39824.kt") + public void testKt39824() throws Exception { + runTest("compiler/testData/codegen/box/inference/kt39824.kt"); + } + @TestMetadata("lastExpressionOfLambdaWithNothingConstraint.kt") public void testLastExpressionOfLambdaWithNothingConstraint() throws Exception { runTest("compiler/testData/codegen/box/inference/lastExpressionOfLambdaWithNothingConstraint.kt");