[FE 1.0] Don't report OVERRIDE_DEPRECATION on default accessors of deprecated properties

^KT-51893 Fixed
This commit is contained in:
Dmitriy Novozhilov
2022-04-15 10:28:45 +04:00
committed by teamcity
parent 3f93f2796d
commit 989cef6c3c
7 changed files with 100 additions and 0 deletions
@@ -8892,6 +8892,12 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag
runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt");
}
@Test
@TestMetadata("duplicatedOverrideDeprecationOnProperty.kt")
public void testDuplicatedOverrideDeprecationOnProperty() throws Exception {
runTest("compiler/testData/diagnostics/tests/deprecated/duplicatedOverrideDeprecationOnProperty.kt");
}
@Test
@TestMetadata("functionUsage.kt")
public void testFunctionUsage() throws Exception {
@@ -8892,6 +8892,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt");
}
@Test
@TestMetadata("duplicatedOverrideDeprecationOnProperty.kt")
public void testDuplicatedOverrideDeprecationOnProperty() throws Exception {
runTest("compiler/testData/diagnostics/tests/deprecated/duplicatedOverrideDeprecationOnProperty.kt");
}
@Test
@TestMetadata("functionUsage.kt")
public void testFunctionUsage() throws Exception {
@@ -8892,6 +8892,12 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac
runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt");
}
@Test
@TestMetadata("duplicatedOverrideDeprecationOnProperty.kt")
public void testDuplicatedOverrideDeprecationOnProperty() throws Exception {
runTest("compiler/testData/diagnostics/tests/deprecated/duplicatedOverrideDeprecationOnProperty.kt");
}
@Test
@TestMetadata("functionUsage.kt")
public void testFunctionUsage() throws Exception {
@@ -7,13 +7,18 @@ package org.jetbrains.kotlin.resolve.checkers
import org.jetbrains.kotlin.config.LanguageFeature.StopPropagatingDeprecationThroughOverrides
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor
import org.jetbrains.kotlin.diagnostics.Errors
import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtNamedDeclaration
import org.jetbrains.kotlin.psi.KtProperty
object DeprecationInheritanceChecker : DeclarationChecker {
override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) {
if (declaration !is KtNamedDeclaration) return
if (declaration is KtProperty && descriptor is PropertyAccessorDescriptor && descriptor.isDefault) {
return
}
val deprecationResolver = context.deprecationResolver
if (!deprecationResolver.areDeprecationsInheritedFromOverriden(descriptor)) return
val (deprecations, message) = if (context.languageVersionSettings.supportsFeature(StopPropagatingDeprecationThroughOverrides)) {
@@ -0,0 +1,45 @@
// FIR_IDENTICAL
// ISSUE: KT-51893
interface A {
@Deprecated("")
val a: String
@Deprecated("")
val b: String
@Deprecated("")
var c: String
@Deprecated("")
var d: String
@Deprecated("")
var e: String
@Deprecated("")
var h: String
}
object B : A {
override val <!OVERRIDE_DEPRECATION!>a<!>: String = ""
override val <!OVERRIDE_DEPRECATION!>b<!>: String
get() = ""
override var <!OVERRIDE_DEPRECATION!>c<!>: String = ""
override var <!OVERRIDE_DEPRECATION!>d<!>: String = ""
get() = field
override var <!OVERRIDE_DEPRECATION!>e<!>: String = ""
set(value) {
field = value
}
override var <!OVERRIDE_DEPRECATION!>h<!>: String = ""
get() = field
set(value) {
field = value
}
}
@@ -0,0 +1,26 @@
package
public interface A {
@kotlin.Deprecated(message = "") public abstract val a: kotlin.String
@kotlin.Deprecated(message = "") public abstract val b: kotlin.String
@kotlin.Deprecated(message = "") public abstract var c: kotlin.String
@kotlin.Deprecated(message = "") public abstract var d: kotlin.String
@kotlin.Deprecated(message = "") public abstract var e: kotlin.String
@kotlin.Deprecated(message = "") public abstract var h: kotlin.String
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
}
public object B : A {
private constructor B()
public open override /*1*/ val a: kotlin.String = ""
public open override /*1*/ val b: kotlin.String
public open override /*1*/ var c: kotlin.String
public open override /*1*/ var d: kotlin.String
public open override /*1*/ var e: kotlin.String
public open override /*1*/ var h: kotlin.String
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
}
@@ -8898,6 +8898,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt");
}
@Test
@TestMetadata("duplicatedOverrideDeprecationOnProperty.kt")
public void testDuplicatedOverrideDeprecationOnProperty() throws Exception {
runTest("compiler/testData/diagnostics/tests/deprecated/duplicatedOverrideDeprecationOnProperty.kt");
}
@Test
@TestMetadata("functionUsage.kt")
public void testFunctionUsage() throws Exception {