From 43cf6623f9e5a6b0d30b611b3f2412d6f593339e Mon Sep 17 00:00:00 2001 From: Mikhail Zarechenskiy Date: Fri, 1 Mar 2019 12:44:56 +0300 Subject: [PATCH] [NI] Added test for controversial common system See KT-23854 --- .../selectFromTwoIncompatibleTypes.kt | 25 +++++++++++++++++ .../selectFromTwoIncompatibleTypes.txt | 28 +++++++++++++++++++ .../checkers/DiagnosticsTestGenerated.java | 5 ++++ .../DiagnosticsUsingJavacTestGenerated.java | 5 ++++ 4 files changed, 63 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.kt create mode 100644 compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.txt diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.kt b/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.kt new file mode 100644 index 00000000000..80b37cee940 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.kt @@ -0,0 +1,25 @@ +// !LANGUAGE: +NewInference +// !DIAGNOSTICS: -UNUSED_PARAMETER + +class Inv + +class A +class B + +fun select(x: K, y: K): K = x +fun generic(x: Inv) {} + +fun test1(a: Inv, b: Inv) { + generic(select(a, b)) +} + +fun test2(a: Inv<*>?, b: Inv<*>) { + generic(a ?: b) + generic(if (a != null) a else b) + generic(a!!) +} + +fun test3(a: Inv, b: Inv) { + generic(select(a, b)) +} + diff --git a/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.txt b/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.txt new file mode 100644 index 00000000000..badbf4d4a07 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.txt @@ -0,0 +1,28 @@ +package + +public fun generic(/*0*/ x: Inv): kotlin.Unit +public fun select(/*0*/ x: K, /*1*/ y: K): K +public fun test1(/*0*/ a: Inv, /*1*/ b: Inv): kotlin.Unit +public fun test2(/*0*/ a: Inv<*>?, /*1*/ b: Inv<*>): kotlin.Unit +public fun test3(/*0*/ a: Inv, /*1*/ b: Inv): kotlin.Unit + +public final class A { + public constructor A() + 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 +} + +public final class B { + public constructor B() + 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 +} + +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/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 40449e139b4..bcbcaf67279 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -9853,6 +9853,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt"); } + @TestMetadata("selectFromTwoIncompatibleTypes.kt") + public void testSelectFromTwoIncompatibleTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.kt"); + } + @TestMetadata("theSameFunctionInArgs.kt") public void testTheSameFunctionInArgs() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.kt"); diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index de1a76459dc..1d070adfff2 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -9848,6 +9848,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inference/commonSystem/nestedLambdas.kt"); } + @TestMetadata("selectFromTwoIncompatibleTypes.kt") + public void testSelectFromTwoIncompatibleTypes() throws Exception { + runTest("compiler/testData/diagnostics/tests/inference/commonSystem/selectFromTwoIncompatibleTypes.kt"); + } + @TestMetadata("theSameFunctionInArgs.kt") public void testTheSameFunctionInArgs() throws Exception { runTest("compiler/testData/diagnostics/tests/inference/commonSystem/theSameFunctionInArgs.kt");