From 35e82d45742af08ea9b862446652f20381d47904 Mon Sep 17 00:00:00 2001 From: Ilya Ryzhenkov Date: Tue, 28 Apr 2015 18:18:57 +0300 Subject: [PATCH] Propagate annotations when performing substitution on constructors #KT-7608 Fixed Tests for deprecated warning on generic constructor. --- .../tests/deprecated/genericConstructorUsage.kt | 8 ++++++++ .../tests/deprecated/genericConstructorUsage.txt | 16 ++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 6 ++++++ .../impl/ConstructorDescriptorImpl.java | 2 +- 4 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt create mode 100644 compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.txt diff --git a/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt b/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt new file mode 100644 index 00000000000..f5c6da93ed7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt @@ -0,0 +1,8 @@ +// !DIAGNOSTICS: -UNUSED_EXPRESSION, -REFLECTION_TYPES_NOT_LOADED, -UNUSED_PARAMETER + +open class C() { + deprecated("") + constructor(p: Int) : this(){} +} + +class D : C(1) \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.txt b/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.txt new file mode 100644 index 00000000000..90ef4ef937a --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.txt @@ -0,0 +1,16 @@ +package + +internal open class C { + public constructor C() + kotlin.deprecated(value = "": kotlin.String) public constructor C(/*0*/ p: kotlin.Int) + 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 +} + +internal final class D : C { + public constructor D() + 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/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index c6b1b58581b..933bb36fc7d 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -3516,6 +3516,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("genericConstructorUsage.kt") + public void testGenericConstructorUsage() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/genericConstructorUsage.kt"); + doTest(fileName); + } + @TestMetadata("imports.kt") public void testImports() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/deprecated/imports.kt"); diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ConstructorDescriptorImpl.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ConstructorDescriptorImpl.java index d2ede361068..659d185798b 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ConstructorDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/impl/ConstructorDescriptorImpl.java @@ -127,7 +127,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements return new ConstructorDescriptorImpl( (ClassDescriptor) newOwner, this, - Annotations.EMPTY, // TODO + getAnnotations(), isPrimary, Kind.DECLARATION, SourceElement.NO_SOURCE