From c3a1643c6c27fce35f0b8fe1739961d0582d8e62 Mon Sep 17 00:00:00 2001 From: "Pavel V. Talanov" Date: Wed, 9 Mar 2016 18:41:00 +0300 Subject: [PATCH] Add test for obsolete KT-6481 Mark deprecated constructor calls with strikethrough --- .../tests/deprecated/deprecatedConstructor.kt | 34 +++++++++++++++++++ .../deprecated/deprecatedConstructor.txt | 26 ++++++++++++++ .../checkers/DiagnosticsTestGenerated.java | 6 ++++ 3 files changed, 66 insertions(+) create mode 100644 compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.kt create mode 100644 compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.txt diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.kt new file mode 100644 index 00000000000..bc50fba3cbe --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.kt @@ -0,0 +1,34 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +// FILE: A.kt +class A(s: String) { + @Deprecated("") + constructor(i: Int) : this(i.toString()) { + + } +} + +// FILE: B.java +public class B extends A { + @Deprecated + public B(int i) { + + } + + public B(String s) { + + } +} + +// FILE: C.kt +class C @Deprecated("") constructor(s: String) { +} + +// FILE: use.kt +fun use(a: A, b: B, c: C) { + A(3) + A("") + B(3) + B("") + C("s") +} diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.txt b/compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.txt new file mode 100644 index 00000000000..e9463a5d81f --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.txt @@ -0,0 +1,26 @@ +package + +public fun use(/*0*/ a: A, /*1*/ b: B, /*2*/ c: C): kotlin.Unit + +public final class A { + @kotlin.Deprecated(message = "") public constructor A(/*0*/ i: kotlin.Int) + public constructor A(/*0*/ s: kotlin.String) + 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 open class B : A { + @kotlin.Deprecated(message = "Deprecated in Java") public constructor B(/*0*/ i: kotlin.Int) + public constructor B(/*0*/ s: kotlin.String!) + 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 C { + @kotlin.Deprecated(message = "") public constructor C(/*0*/ s: kotlin.String) + 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 fd7bd417954..8433d6cc4af 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -5088,6 +5088,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("deprecatedConstructor.kt") + public void testDeprecatedConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/deprecatedConstructor.kt"); + doTest(fileName); + } + @TestMetadata("deprecatedError.kt") public void testDeprecatedError() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/deprecatedError.kt");