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
|
||||
USER_TYPE
|
||||
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
|
||||
USER_TYPE
|
||||
USER_TYPE
|
||||
|
||||
-10
@@ -58,16 +58,6 @@ PsiJetFileStubImpl[package=test]
|
||||
USER_TYPE
|
||||
REFERENCE_EXPRESSION[referencedName=test]
|
||||
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
|
||||
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
|
||||
// @JvmField, so checking the current field only should be enough.
|
||||
val hasJvmField = oldField.hasAnnotation(JvmAbi.JVM_FIELD_ANNOTATION_FQ_NAME)
|
||||
if (oldParent.isCompanion && (!oldParent.parentAsClass.isJvmInterface || hasJvmField)) {
|
||||
parent = oldParent.parentAsClass
|
||||
annotations = if (DescriptorVisibilities.isPrivate(oldParent.visibility)) {
|
||||
context.createJvmIrBuilder(this.symbol).run {
|
||||
filterOutAnnotations(
|
||||
DeprecationResolver.JAVA_DEPRECATED,
|
||||
oldField.annotations
|
||||
) + irCall(irSymbols.javaLangDeprecatedConstructorWithDeprecatedFlag)
|
||||
}
|
||||
} else oldField.annotations
|
||||
val shouldMoveFields = oldParent.isCompanion && (!oldParent.parentAsClass.isJvmInterface || hasJvmField)
|
||||
if (shouldMoveFields) {
|
||||
parent = oldParent.parentAsClass
|
||||
val isPrivate = DescriptorVisibilities.isPrivate(oldField.visibility)
|
||||
val parentIsPrivate = DescriptorVisibilities.isPrivate(oldParent.visibility)
|
||||
annotations = if (parentIsPrivate && !isPrivate) {
|
||||
context.createJvmIrBuilder(this.symbol).run {
|
||||
filterOutAnnotations(
|
||||
DeprecationResolver.JAVA_DEPRECATED,
|
||||
oldField.annotations
|
||||
) + irCall(irSymbols.javaLangDeprecatedConstructorWithDeprecatedFlag)
|
||||
}
|
||||
} else {
|
||||
oldField.annotations
|
||||
}
|
||||
} else {
|
||||
parent = oldParent
|
||||
annotations = oldField.annotations
|
||||
}
|
||||
|
||||
initializer = oldField.initializer?.patchDeclarationParents(this)
|
||||
oldField.replaceThisByStaticReference(fieldsForObjectInstances, oldParent, oldParent.thisReceiver!!)
|
||||
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 {
|
||||
|
||||
private companion object {
|
||||
@@ -29,4 +38,4 @@ interface TestJvmField {
|
||||
@JvmField
|
||||
val test3: String = "3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,28 @@ public final class TestClass {
|
||||
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
|
||||
final class TestConst$Companion {
|
||||
// source: 'privateCompanionFields.kt'
|
||||
|
||||
@@ -19,6 +19,28 @@ public final class TestClass {
|
||||
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
|
||||
final class TestConst$Companion {
|
||||
// source: 'privateCompanionFields.kt'
|
||||
|
||||
Reference in New Issue
Block a user