Remove unnecessary deprecation annotation
Private members on private companion objects have proper visibility so there is no need for the @Deprecated annotation. ^KT-54539 Fixed
This commit is contained in:
committed by
Alexander Udalov
parent
b42a7be0de
commit
9f3d8130db
analysis/decompiled/decompiler-to-file-stubs/testData/clsFileStubBuilder/Annotations/Annotations.txt
Vendored
-10
@@ -52,16 +52,6 @@ PsiJetFileStubImpl[package=]
|
|||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION[referencedName=f]
|
REFERENCE_EXPRESSION[referencedName=f]
|
||||||
ANNOTATION_ENTRY[hasValueArguments=false, shortName=Deprecated]
|
|
||||||
ANNOTATION_TARGET[useSiteTarget=FIELD]
|
|
||||||
CONSTRUCTOR_CALLEE
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
USER_TYPE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION[referencedName=java]
|
|
||||||
REFERENCE_EXPRESSION[referencedName=lang]
|
|
||||||
REFERENCE_EXPRESSION[referencedName=Deprecated]
|
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
|
|||||||
-10
@@ -58,16 +58,6 @@ PsiJetFileStubImpl[package=test]
|
|||||||
USER_TYPE
|
USER_TYPE
|
||||||
REFERENCE_EXPRESSION[referencedName=test]
|
REFERENCE_EXPRESSION[referencedName=test]
|
||||||
REFERENCE_EXPRESSION[referencedName=A]
|
REFERENCE_EXPRESSION[referencedName=A]
|
||||||
ANNOTATION_ENTRY[hasValueArguments=false, shortName=Deprecated]
|
|
||||||
ANNOTATION_TARGET[useSiteTarget=FIELD]
|
|
||||||
CONSTRUCTOR_CALLEE
|
|
||||||
TYPE_REFERENCE
|
|
||||||
USER_TYPE
|
|
||||||
USER_TYPE
|
|
||||||
USER_TYPE
|
|
||||||
REFERENCE_EXPRESSION[referencedName=java]
|
|
||||||
REFERENCE_EXPRESSION[referencedName=lang]
|
|
||||||
REFERENCE_EXPRESSION[referencedName=Deprecated]
|
|
||||||
TYPE_REFERENCE
|
TYPE_REFERENCE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
USER_TYPE
|
USER_TYPE
|
||||||
|
|||||||
+15
-11
@@ -79,21 +79,25 @@ class JvmCachedDeclarations(
|
|||||||
// It is an error to annotate only some of the fields of an interface companion with
|
// It is an error to annotate only some of the fields of an interface companion with
|
||||||
// @JvmField, so checking the current field only should be enough.
|
// @JvmField, so checking the current field only should be enough.
|
||||||
val hasJvmField = oldField.hasAnnotation(JvmAbi.JVM_FIELD_ANNOTATION_FQ_NAME)
|
val hasJvmField = oldField.hasAnnotation(JvmAbi.JVM_FIELD_ANNOTATION_FQ_NAME)
|
||||||
if (oldParent.isCompanion && (!oldParent.parentAsClass.isJvmInterface || hasJvmField)) {
|
val shouldMoveFields = oldParent.isCompanion && (!oldParent.parentAsClass.isJvmInterface || hasJvmField)
|
||||||
parent = oldParent.parentAsClass
|
if (shouldMoveFields) {
|
||||||
annotations = if (DescriptorVisibilities.isPrivate(oldParent.visibility)) {
|
parent = oldParent.parentAsClass
|
||||||
context.createJvmIrBuilder(this.symbol).run {
|
val isPrivate = DescriptorVisibilities.isPrivate(oldField.visibility)
|
||||||
filterOutAnnotations(
|
val parentIsPrivate = DescriptorVisibilities.isPrivate(oldParent.visibility)
|
||||||
DeprecationResolver.JAVA_DEPRECATED,
|
annotations = if (parentIsPrivate && !isPrivate) {
|
||||||
oldField.annotations
|
context.createJvmIrBuilder(this.symbol).run {
|
||||||
) + irCall(irSymbols.javaLangDeprecatedConstructorWithDeprecatedFlag)
|
filterOutAnnotations(
|
||||||
}
|
DeprecationResolver.JAVA_DEPRECATED,
|
||||||
} else oldField.annotations
|
oldField.annotations
|
||||||
|
) + irCall(irSymbols.javaLangDeprecatedConstructorWithDeprecatedFlag)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
oldField.annotations
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
parent = oldParent
|
parent = oldParent
|
||||||
annotations = oldField.annotations
|
annotations = oldField.annotations
|
||||||
}
|
}
|
||||||
|
|
||||||
initializer = oldField.initializer?.patchDeclarationParents(this)
|
initializer = oldField.initializer?.patchDeclarationParents(this)
|
||||||
oldField.replaceThisByStaticReference(fieldsForObjectInstances, oldParent, oldParent.thisReceiver!!)
|
oldField.replaceThisByStaticReference(fieldsForObjectInstances, oldParent, oldParent.thisReceiver!!)
|
||||||
origin = if (irProperty.parentAsClass.isCompanion) JvmLoweredDeclarationOrigin.COMPANION_PROPERTY_BACKING_FIELD else origin
|
origin = if (irProperty.parentAsClass.isCompanion) JvmLoweredDeclarationOrigin.COMPANION_PROPERTY_BACKING_FIELD else origin
|
||||||
|
|||||||
@@ -16,6 +16,15 @@ class TestClass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class TestClass2 {
|
||||||
|
|
||||||
|
private companion object {
|
||||||
|
val testPublic: String = "1"
|
||||||
|
private val testPrivate: String = "2"
|
||||||
|
const val testPublicConst: String = "3"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
interface TestConst {
|
interface TestConst {
|
||||||
|
|
||||||
private companion object {
|
private companion object {
|
||||||
@@ -29,4 +38,4 @@ interface TestJvmField {
|
|||||||
@JvmField
|
@JvmField
|
||||||
val test3: String = "3"
|
val test3: String = "3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,28 @@ public final class TestClass {
|
|||||||
private final inner class TestClass$Companion
|
private final inner class TestClass$Companion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
final class TestClass2$Companion {
|
||||||
|
// source: 'privateCompanionFields.kt'
|
||||||
|
private method <init>(): void
|
||||||
|
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||||
|
public final @org.jetbrains.annotations.NotNull method getTestPublic(): java.lang.String
|
||||||
|
private final inner class TestClass2$Companion
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class TestClass2 {
|
||||||
|
// source: 'privateCompanionFields.kt'
|
||||||
|
private final static @org.jetbrains.annotations.NotNull field Companion: TestClass2$Companion
|
||||||
|
private deprecated final static @java.lang.Deprecated field testPrivate: java.lang.String
|
||||||
|
private deprecated final static @java.lang.Deprecated @org.jetbrains.annotations.NotNull field testPublic: java.lang.String
|
||||||
|
public deprecated final static @java.lang.Deprecated @org.jetbrains.annotations.NotNull field testPublicConst: java.lang.String
|
||||||
|
static method <clinit>(): void
|
||||||
|
public method <init>(): void
|
||||||
|
public synthetic final static method access$getTestPublic$cp(): java.lang.String
|
||||||
|
private final inner class TestClass2$Companion
|
||||||
|
}
|
||||||
|
|
||||||
@kotlin.Metadata
|
@kotlin.Metadata
|
||||||
final class TestConst$Companion {
|
final class TestConst$Companion {
|
||||||
// source: 'privateCompanionFields.kt'
|
// source: 'privateCompanionFields.kt'
|
||||||
|
|||||||
@@ -19,6 +19,28 @@ public final class TestClass {
|
|||||||
private final inner class TestClass$Companion
|
private final inner class TestClass$Companion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
final class TestClass2$Companion {
|
||||||
|
// source: 'privateCompanionFields.kt'
|
||||||
|
private method <init>(): void
|
||||||
|
public synthetic method <init>(p0: kotlin.jvm.internal.DefaultConstructorMarker): void
|
||||||
|
public final @org.jetbrains.annotations.NotNull method getTestPublic(): java.lang.String
|
||||||
|
private final inner class TestClass2$Companion
|
||||||
|
}
|
||||||
|
|
||||||
|
@kotlin.Metadata
|
||||||
|
public final class TestClass2 {
|
||||||
|
// source: 'privateCompanionFields.kt'
|
||||||
|
private final static @org.jetbrains.annotations.NotNull field Companion: TestClass2$Companion
|
||||||
|
private final static @org.jetbrains.annotations.NotNull field testPrivate: java.lang.String
|
||||||
|
private final static @org.jetbrains.annotations.NotNull field testPublic: java.lang.String
|
||||||
|
public deprecated final static @java.lang.Deprecated @org.jetbrains.annotations.NotNull field testPublicConst: java.lang.String
|
||||||
|
static method <clinit>(): void
|
||||||
|
public method <init>(): void
|
||||||
|
public synthetic final static method access$getTestPublic$cp(): java.lang.String
|
||||||
|
private final inner class TestClass2$Companion
|
||||||
|
}
|
||||||
|
|
||||||
@kotlin.Metadata
|
@kotlin.Metadata
|
||||||
final class TestConst$Companion {
|
final class TestConst$Companion {
|
||||||
// source: 'privateCompanionFields.kt'
|
// source: 'privateCompanionFields.kt'
|
||||||
|
|||||||
Reference in New Issue
Block a user