From ca997de6a7b4743a46c781222e64d4235b5c57f2 Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Tue, 18 Jun 2019 16:28:13 +0300 Subject: [PATCH] [NI] Test data to understand changes in the next commit ##KT-31969 In Progress --- .../fir/FirDiagnosticsSmokeTestGenerated.java | 15 ++++++++++ .../tests/inference/commonSystem/kt31969.kt | 12 ++++++++ .../tests/inference/commonSystem/kt31969.txt | 11 ++++++++ .../postponedCompletionWithExactAnnotation.kt | 27 ++++++++++++++++++ ...postponedCompletionWithExactAnnotation.txt | 12 ++++++++ ...stponedCompletionWithExactAnnotation_ni.kt | 28 +++++++++++++++++++ ...tponedCompletionWithExactAnnotation_ni.txt | 12 ++++++++ .../checkers/DiagnosticsTestGenerated.java | 15 ++++++++++ .../DiagnosticsUsingJavacTestGenerated.java | 15 ++++++++++ 9 files changed, 147 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.txt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.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 b427bcfc2da..361d76d658b 100644 --- a/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java +++ b/compiler/fir/resolve/tests/org/jetbrains/kotlin/fir/FirDiagnosticsSmokeTestGenerated.java @@ -10001,6 +10001,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt30300.kt"); } + @TestMetadata("kt31969.kt") + public void testKt31969() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.kt"); + } + @TestMetadata("kt3372toCollection.kt") public void testKt3372toCollection() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.kt"); @@ -10011,6 +10016,16 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok runTest("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt"); } + @TestMetadata("postponedCompletionWithExactAnnotation.kt") + public void testPostponedCompletionWithExactAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.kt"); + } + + @TestMetadata("postponedCompletionWithExactAnnotation_ni.kt") + public void testPostponedCompletionWithExactAnnotation_ni() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.kt"); + } + @TestMetadata("selectFromCovariantAndContravariantTypes.kt") public void testSelectFromCovariantAndContravariantTypes() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.kt"); diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.kt new file mode 100644 index 00000000000..24beb4355a6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.kt @@ -0,0 +1,12 @@ +// !DIAGNOSTICS: -UNUSED_VARIABLE +// !WITH_NEW_INFERENCE + +open class View + +fun test() { + val target = foo() ?: foo() ?: run {} +} + +fun foo(): T? { + return null +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.txt new file mode 100644 index 00000000000..a2e47b4dc90 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.txt @@ -0,0 +1,11 @@ +package + +public fun foo(): T? +public fun test(): kotlin.Unit + +public open class View { + public constructor View() + 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/inference/commonSystem/postponedCompletionWithExactAnnotation.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.kt new file mode 100644 index 00000000000..66f4cee761e --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.kt @@ -0,0 +1,27 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface ISample + +fun elvisSimple(x: K?, y: K): K = y + +@Suppress("INVISIBLE_REFERENCE") +fun elvisExact(x: K?, y: K): @kotlin.internal.Exact K = y + +fun materialize(): T? = TODO() + +fun test(nullableSample: ISample, any: Any) { + elvisSimple( + nullableSample, + materialize() + ) + + elvisSimple( + elvisSimple(nullableSample, materialize()), + any + ) + + elvisSimple( + elvisExact(nullableSample, materialize()), + any + ) +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.txt new file mode 100644 index 00000000000..84135a36988 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.txt @@ -0,0 +1,12 @@ +package + +@kotlin.Suppress(names = {"INVISIBLE_REFERENCE"}) public fun elvisExact(/*0*/ x: K?, /*1*/ y: K): K +public fun elvisSimple(/*0*/ x: K?, /*1*/ y: K): K +public fun materialize(): T? +public fun test(/*0*/ nullableSample: ISample, /*1*/ any: kotlin.Any): kotlin.Unit + +public interface ISample { + 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/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.kt new file mode 100644 index 00000000000..19fc23b88aa --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.kt @@ -0,0 +1,28 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface ISample + +fun elvisSimple(x: K?, y: K): K = y + +@Suppress("INVISIBLE_REFERENCE") +fun elvisExact(x: K?, y: K): @kotlin.internal.Exact K = y + +fun materialize(): T? = null + +fun test(nullableSample: ISample, any: Any) { + elvisSimple( + nullableSample, + materialize() + ) + + elvisSimple( + elvisSimple(nullableSample, materialize()), + any + ) + + elvisSimple( + elvisExact(nullableSample, materialize()), + any + ) +} diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.txt new file mode 100644 index 00000000000..84135a36988 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.txt @@ -0,0 +1,12 @@ +package + +@kotlin.Suppress(names = {"INVISIBLE_REFERENCE"}) public fun elvisExact(/*0*/ x: K?, /*1*/ y: K): K +public fun elvisSimple(/*0*/ x: K?, /*1*/ y: K): K +public fun materialize(): T? +public fun test(/*0*/ nullableSample: ISample, /*1*/ any: kotlin.Any): kotlin.Unit + +public interface ISample { + 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/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 4cb4d082eee..4ff23e87928 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -10008,6 +10008,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt30300.kt"); } + @TestMetadata("kt31969.kt") + public void testKt31969() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.kt"); + } + @TestMetadata("kt3372toCollection.kt") public void testKt3372toCollection() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.kt"); @@ -10018,6 +10023,16 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt"); } + @TestMetadata("postponedCompletionWithExactAnnotation.kt") + public void testPostponedCompletionWithExactAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.kt"); + } + + @TestMetadata("postponedCompletionWithExactAnnotation_ni.kt") + public void testPostponedCompletionWithExactAnnotation_ni() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.kt"); + } + @TestMetadata("selectFromCovariantAndContravariantTypes.kt") public void testSelectFromCovariantAndContravariantTypes() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index ec2dbabc21d..1e9c707b053 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -10003,6 +10003,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt30300.kt"); } + @TestMetadata("kt31969.kt") + public void testKt31969() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt31969.kt"); + } + @TestMetadata("kt3372toCollection.kt") public void testKt3372toCollection() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/kt3372toCollection.kt"); @@ -10013,6 +10018,16 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt"); } + @TestMetadata("postponedCompletionWithExactAnnotation.kt") + public void testPostponedCompletionWithExactAnnotation() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation.kt"); + } + + @TestMetadata("postponedCompletionWithExactAnnotation_ni.kt") + public void testPostponedCompletionWithExactAnnotation_ni() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/postponedCompletionWithExactAnnotation_ni.kt"); + } + @TestMetadata("selectFromCovariantAndContravariantTypes.kt") public void testSelectFromCovariantAndContravariantTypes() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/selectFromCovariantAndContravariantTypes.kt");