From 452cd49c5e653113ec6f759162d2adb0af4c6cb1 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Mon, 7 Sep 2015 20:37:07 +0300 Subject: [PATCH] Disallowed @Deprecated for local variables and parameters --- compiler/testData/builtin-classes.txt | 2 +- compiler/testData/compileJavaAgainstKotlin/class/kt4050.kt | 4 +++- compiler/testData/compileJavaAgainstKotlin/class/kt4050.txt | 6 +++++- core/builtins/src/kotlin/Annotations.kt | 3 +-- .../decompiler/decompiledText/Annotations.expected.kt | 2 +- .../decompiler/decompiledText/Annotations/Annotations.kt | 2 +- 6 files changed, 12 insertions(+), 7 deletions(-) diff --git a/compiler/testData/builtin-classes.txt b/compiler/testData/builtin-classes.txt index 7a99be8d95e..dc34fc2bdd9 100644 --- a/compiler/testData/builtin-classes.txt +++ b/compiler/testData/builtin-classes.txt @@ -283,7 +283,7 @@ public interface Comparable { public abstract fun compareTo(/*0*/ other: T): kotlin.Int } -@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.PROPERTY_GETTER, AnnotationTarget.LOCAL_VARIABLE, AnnotationTarget.VALUE_PARAMETER}) @kotlin.annotation.MustBeDocumented() @kotlin.annotation.annotation() public final class Deprecated : kotlin.Annotation { +@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.CLASS, AnnotationTarget.FUNCTION, AnnotationTarget.PROPERTY, AnnotationTarget.ANNOTATION_CLASS, AnnotationTarget.CONSTRUCTOR, AnnotationTarget.PROPERTY_SETTER, AnnotationTarget.PROPERTY_GETTER}) @kotlin.annotation.MustBeDocumented() @kotlin.annotation.annotation() public final class Deprecated : kotlin.Annotation { /*primary*/ public constructor Deprecated(/*0*/ value: kotlin.String, /*1*/ replaceWith: kotlin.ReplaceWith = ...) public final val replaceWith: kotlin.ReplaceWith public final fun (): kotlin.ReplaceWith diff --git a/compiler/testData/compileJavaAgainstKotlin/class/kt4050.kt b/compiler/testData/compileJavaAgainstKotlin/class/kt4050.kt index 2248f6160f7..3fce742cf7a 100644 --- a/compiler/testData/compileJavaAgainstKotlin/class/kt4050.kt +++ b/compiler/testData/compileJavaAgainstKotlin/class/kt4050.kt @@ -1,6 +1,8 @@ package test -enum class MyEnum(@param:Deprecated("") @property:Deprecated("") val ord: Int) { +annotation class AAA + +enum class MyEnum(@param:AAA @property:Deprecated("") val ord: Int) { ENTRY(239); fun f(@java.lang.Deprecated p: Int) { diff --git a/compiler/testData/compileJavaAgainstKotlin/class/kt4050.txt b/compiler/testData/compileJavaAgainstKotlin/class/kt4050.txt index 403e67f0f40..e8bd2169416 100644 --- a/compiler/testData/compileJavaAgainstKotlin/class/kt4050.txt +++ b/compiler/testData/compileJavaAgainstKotlin/class/kt4050.txt @@ -1,9 +1,13 @@ package test +@kotlin.annotation.annotation() public final class AAA : kotlin.Annotation { + public constructor AAA() +} + public final enum class MyEnum : kotlin.Enum { enum entry ENTRY - private constructor MyEnum(/*0*/ @kotlin.Deprecated(value = "") kotlin.Int) + private constructor MyEnum(/*0*/ @test.AAA() kotlin.Int) @kotlin.Deprecated(value = "") public final val ord: kotlin.Int protected final /*fake_override*/ fun clone(): kotlin.Any public final /*fake_override*/ fun compareTo(/*0*/ test.MyEnum): kotlin.Int diff --git a/core/builtins/src/kotlin/Annotations.kt b/core/builtins/src/kotlin/Annotations.kt index 3cb3f3600fb..4949c21386f 100644 --- a/core/builtins/src/kotlin/Annotations.kt +++ b/core/builtins/src/kotlin/Annotations.kt @@ -36,8 +36,7 @@ public annotation class data * @property replaceWith if present, specifies a code fragment which should be used as a replacement for * the deprecated API usage. */ -@Target(CLASS, FUNCTION, PROPERTY, ANNOTATION_CLASS, CONSTRUCTOR, PROPERTY_SETTER, PROPERTY_GETTER, - LOCAL_VARIABLE, VALUE_PARAMETER) +@Target(CLASS, FUNCTION, PROPERTY, ANNOTATION_CLASS, CONSTRUCTOR, PROPERTY_SETTER, PROPERTY_GETTER) @MustBeDocumented public annotation class Deprecated(val value: String, val replaceWith: ReplaceWith = ReplaceWith("")) diff --git a/idea/testData/decompiler/decompiledText/Annotations.expected.kt b/idea/testData/decompiler/decompiledText/Annotations.expected.kt index 158ff467670..1b93e5b9614 100644 --- a/idea/testData/decompiler/decompiledText/Annotations.expected.kt +++ b/idea/testData/decompiler/decompiledText/Annotations.expected.kt @@ -6,5 +6,5 @@ package test @dependency.A @dependency.B @dependency.C @kotlin.data public final class Annotations public constructor() { @dependency.A @dependency.B @dependency.C @kotlin.inline public final val p: @dependency.B kotlin.Int /* compiled code */ - @dependency.A @dependency.B @dependency.C @kotlin.inline public final fun f(@dependency.A @dependency.B @dependency.C @kotlin.Deprecated i: @dependency.A kotlin.Int): kotlin.Unit { /* compiled code */ } + @dependency.A @dependency.B @dependency.C @kotlin.inline public final fun f(@dependency.A @dependency.B @dependency.C i: @dependency.A kotlin.Int): kotlin.Unit { /* compiled code */ } } \ No newline at end of file diff --git a/idea/testData/decompiler/decompiledText/Annotations/Annotations.kt b/idea/testData/decompiler/decompiledText/Annotations/Annotations.kt index 8fb9d90824b..bed0344128d 100644 --- a/idea/testData/decompiler/decompiledText/Annotations/Annotations.kt +++ b/idea/testData/decompiler/decompiledText/Annotations/Annotations.kt @@ -4,7 +4,7 @@ import dependency.* data @A("a") @B(1) @C class Annotations { - inline @A("f") @B(2) @C fun f(@A("i") @B(3) @C @Deprecated("1") i: @A("int") Int) { + inline @A("f") @B(2) @C fun f(@A("i") @B(3) @C i: @A("int") Int) { } inline @A("p") @B(3) @C val p: @B(4) Int = 2