From 8949ffbef18db0b82c4dd64256645ba48d1c9d54 Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Mon, 19 Sep 2016 13:26:18 +0300 Subject: [PATCH] Do not report deprecation on members of deprecated companion This deprecation is reported on the companion itself anyway --- .../src/org/jetbrains/kotlin/resolve/deprecationUtil.kt | 9 +-------- .../diagnostics/tests/deprecated/companionObjectUsage.kt | 4 ++-- idea/testData/highlighter/deprecated/ClassObject.kt | 6 +++--- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt index 50dea404ea0..624053b8860 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecationUtil.kt @@ -112,7 +112,7 @@ private fun deprecationByOverridden(root: CallableMemberDescriptor): Deprecation return } else -> { - overriddenDescriptors.forEach { traverse(it) } + overriddenDescriptors.forEach(::traverse) } } } @@ -147,13 +147,6 @@ private fun DeclarationDescriptor.getDeprecationByAnnotation(): DeprecatedByAnno val propertyAnnotation = propertyDescriptor.getDeclaredDeprecatedAnnotation() if (propertyAnnotation != null) return DeprecatedByAnnotation(propertyAnnotation, propertyDescriptor) - - val classDescriptor = containingDeclaration as? ClassDescriptor - if (classDescriptor != null && classDescriptor.isCompanionObject) { - val classAnnotation = classDescriptor.getDeclaredDeprecatedAnnotation() - if (classAnnotation != null) - return DeprecatedByAnnotation(classAnnotation, classDescriptor) - } } } return null diff --git a/compiler/testData/diagnostics/tests/deprecated/companionObjectUsage.kt b/compiler/testData/diagnostics/tests/deprecated/companionObjectUsage.kt index 1d8dc3baece..2ad875d30b7 100644 --- a/compiler/testData/diagnostics/tests/deprecated/companionObjectUsage.kt +++ b/compiler/testData/diagnostics/tests/deprecated/companionObjectUsage.kt @@ -8,8 +8,8 @@ class Another { fun first() { Another.use() - Another.Companion.USE // TODO - Another.USE // TODO + Another.Companion.USE + Another.USE } fun useCompanion() { diff --git a/idea/testData/highlighter/deprecated/ClassObject.kt b/idea/testData/highlighter/deprecated/ClassObject.kt index dc745a8ec4e..61ec78da6bf 100644 --- a/idea/testData/highlighter/deprecated/ClassObject.kt +++ b/idea/testData/highlighter/deprecated/ClassObject.kt @@ -1,13 +1,13 @@ fun test() { - MyClass.test + MyClass.test MyClass() val a: MyClass? = null val b: MyTrait? = null - MyTrait.test + MyTrait.test MyTrait.Companion MyTrait MyClass.Companion - MyClass.Companion.test + MyClass.Companion.test a == b }