diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java index 1b827793d64..110be18c9b8 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsTestGenerated.java @@ -8598,15 +8598,27 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti } @Test - @TestMetadata("deprecatedInheritance.kt") - public void testDeprecatedInheritance() throws Exception { - runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.kt"); + @TestMetadata("deprecatedInheritance_after.kt") + public void testDeprecatedInheritance_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.kt"); } @Test - @TestMetadata("deprecatedPropertyInheritance.kt") - public void testDeprecatedPropertyInheritance() throws Exception { - runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.kt"); + @TestMetadata("deprecatedInheritance_before.kt") + public void testDeprecatedInheritance_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.kt"); + } + + @Test + @TestMetadata("deprecatedPropertyInheritance_after.kt") + public void testDeprecatedPropertyInheritance_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.kt"); + } + + @Test + @TestMetadata("deprecatedPropertyInheritance_before.kt") + public void testDeprecatedPropertyInheritance_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt"); } @Test diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java index d3d04479588..3784b1b3e6f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendDiagnosticsWithLightTreeTestGenerated.java @@ -8598,15 +8598,27 @@ public class FirOldFrontendDiagnosticsWithLightTreeTestGenerated extends Abstrac } @Test - @TestMetadata("deprecatedInheritance.kt") - public void testDeprecatedInheritance() throws Exception { - runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.kt"); + @TestMetadata("deprecatedInheritance_after.kt") + public void testDeprecatedInheritance_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.kt"); } @Test - @TestMetadata("deprecatedPropertyInheritance.kt") - public void testDeprecatedPropertyInheritance() throws Exception { - runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.kt"); + @TestMetadata("deprecatedInheritance_before.kt") + public void testDeprecatedInheritance_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.kt"); + } + + @Test + @TestMetadata("deprecatedPropertyInheritance_after.kt") + public void testDeprecatedPropertyInheritance_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.kt"); + } + + @Test + @TestMetadata("deprecatedPropertyInheritance_before.kt") + public void testDeprecatedPropertyInheritance_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt"); } @Test diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index edaa5a0f18c..fe01f4a669a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.VarianceConflictDiagnosticData; import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData; import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall; import org.jetbrains.kotlin.resolve.calls.tower.WrongResolutionToClassifier; +import org.jetbrains.kotlin.resolve.deprecation.DescriptorBasedDeprecation; import org.jetbrains.kotlin.resolve.multiplatform.ExpectActualCompatibility.Incompatible; import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData; import org.jetbrains.kotlin.types.KotlinType; @@ -98,6 +99,8 @@ public interface Errors { VERSION_REQUIREMENT_DEPRECATION = DiagnosticFactory3.create(WARNING); DiagnosticFactory3> VERSION_REQUIREMENT_DEPRECATION_ERROR = DiagnosticFactory3.create(ERROR); + // descriptor and deprecation infos are needed only for IDE quickfix for this warning + DiagnosticFactory3> OVERRIDE_DEPRECATION = DiagnosticFactory3.create(WARNING, DECLARATION_NAME); DiagnosticFactory0 DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED = DiagnosticFactory0.create(ERROR); DiagnosticFactory0 DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL = DiagnosticFactory0.create(ERROR); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 00cd59b24e5..f3a08f6ff4a 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -394,6 +394,8 @@ public class DefaultErrorMessages { (obj, renderingContext) -> obj.equals(VersionRequirement.Version.INFINITY) ? "" : " is only available since Kotlin " + obj.asString() + " and", versionRequirementMessage); + MAP.put(OVERRIDE_DEPRECATION, "This declaration overrides deprecated member but not marked as deprecated itself. {0}Please add @Deprecated annotation or suppress", TO_STRING, TO_STRING, TO_STRING); + MAP.put(DEPRECATED_SINCE_KOTLIN_WITHOUT_DEPRECATED, "DeprecatedSinceKotlin annotation can be used only together with Deprecated annotation"); MAP.put(DEPRECATED_SINCE_KOTLIN_WITH_DEPRECATED_LEVEL, "DeprecatedSinceKotlin annotation can be used only with unspecified deprecation level of Deprecated annotation"); MAP.put(DEPRECATED_SINCE_KOTLIN_WITH_UNORDERED_VERSIONS, "Values of DeprecatedSinceKotlin annotation should be ordered so 'warningSince' <= 'errorSince' <= 'hiddenSince' if specified"); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt index 6f8757040b7..d5a6fc72135 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/PlatformConfiguratorBase.kt @@ -38,6 +38,7 @@ private val DEFAULT_DECLARATION_CHECKERS = listOf( TrailingCommaDeclarationChecker, MissingDependencySupertypeChecker.ForDeclarations, FunInterfaceDeclarationChecker(), + DeprecationInheritanceChecker, DeprecatedSinceKotlinAnnotationChecker, ContractDescriptionBlockChecker, PrivateInlineFunctionsReturningAnonymousObjectsChecker, diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecationInheritanceChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecationInheritanceChecker.kt new file mode 100644 index 00000000000..4329e558386 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/DeprecationInheritanceChecker.kt @@ -0,0 +1,26 @@ +/* + * Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.resolve.checkers + +import org.jetbrains.kotlin.config.LanguageFeature.StopPropagatingDeprecationThroughOverrides +import org.jetbrains.kotlin.descriptors.DeclarationDescriptor +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.psi.KtNamedDeclaration + +object DeprecationInheritanceChecker : DeclarationChecker { + override fun check(declaration: KtDeclaration, descriptor: DeclarationDescriptor, context: DeclarationCheckerContext) { + if (declaration !is KtNamedDeclaration) return + val deprecationResolver = context.deprecationResolver + if (!deprecationResolver.areDeprecationsInheritedFromOverriden(descriptor)) return + val (deprecations, message) = if (context.languageVersionSettings.supportsFeature(StopPropagatingDeprecationThroughOverrides)) { + deprecationResolver.getHiddenDeprecationsFromOverriden(descriptor) to "" + } else { + deprecationResolver.getDeprecations(descriptor) to "This deprecation won't be inherited in kotlin 1.7. " + } + context.trace.report(Errors.OVERRIDE_DEPRECATION.on(declaration, message, descriptor, deprecations)) + } +} diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecation/DeprecationResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecation/DeprecationResolver.kt index 29d7575e3f1..81e0c02b47c 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecation/DeprecationResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/deprecation/DeprecationResolver.kt @@ -7,10 +7,7 @@ package org.jetbrains.kotlin.resolve.deprecation import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.builtins.StandardNames -import org.jetbrains.kotlin.config.ApiVersion -import org.jetbrains.kotlin.config.KotlinCompilerVersion -import org.jetbrains.kotlin.config.LanguageVersionSettings -import org.jetbrains.kotlin.config.MavenComparableVersion +import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.DescriptorDerivedFromTypeAlias import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor @@ -27,23 +24,46 @@ import org.jetbrains.kotlin.resolve.checkers.ExperimentalUsageChecker import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameSafe import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedMemberDescriptor +import org.jetbrains.kotlin.storage.MemoizedFunctionToNotNull import org.jetbrains.kotlin.storage.StorageManager import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.addToStdlib.safeAs +import kotlin.contracts.ExperimentalContracts +import kotlin.contracts.contract class DeprecationResolver( storageManager: StorageManager, private val languageVersionSettings: LanguageVersionSettings, private val deprecationSettings: DeprecationSettings ) { - private val deprecations = storageManager.createMemoizedFunction { descriptor: DeclarationDescriptor -> - val deprecations = descriptor.getOwnDeprecations() - when { - deprecations.isNotEmpty() -> deprecations - descriptor is CallableMemberDescriptor -> listOfNotNull(deprecationByOverridden(descriptor)) - else -> emptyList() + private val deprecations: MemoizedFunctionToNotNull = + storageManager.createMemoizedFunction { descriptor -> + val deprecations = descriptor.getOwnDeprecations() + when { + deprecations.isNotEmpty() -> DeprecationInfo(deprecations, hasInheritedDeprecations = false) + descriptor is CallableMemberDescriptor -> { + val inheritedDeprecations = listOfNotNull(deprecationByOverridden(descriptor)) + when (inheritedDeprecations.isNotEmpty()) { + true -> when (languageVersionSettings.supportsFeature(LanguageFeature.StopPropagatingDeprecationThroughOverrides)) { + true -> DeprecationInfo(emptyList(), hasInheritedDeprecations = true, inheritedDeprecations) + false -> DeprecationInfo(inheritedDeprecations, hasInheritedDeprecations = true) + } + false -> DeprecationInfo.EMPTY + } + } + else -> DeprecationInfo.EMPTY + } + } + + private data class DeprecationInfo( + val deprecations: List, + val hasInheritedDeprecations: Boolean, + val hiddenInheritedDeprecations: List = emptyList() + ) { + companion object { + val EMPTY = DeprecationInfo(emptyList(), hasInheritedDeprecations = false, emptyList()) } } @@ -52,7 +72,18 @@ class DeprecationResolver( } fun getDeprecations(descriptor: DeclarationDescriptor): List = - deprecations(descriptor.original) + deprecations(descriptor.original).deprecations + + @OptIn(ExperimentalContracts::class) + fun areDeprecationsInheritedFromOverriden(descriptor: DeclarationDescriptor): Boolean { + contract { + returns(true) implies (descriptor is CallableMemberDescriptor) + } + return deprecations(descriptor.original).hasInheritedDeprecations + } + + fun getHiddenDeprecationsFromOverriden(descriptor: DeclarationDescriptor): List = + deprecations(descriptor.original).hiddenInheritedDeprecations fun isDeprecatedHidden(descriptor: DeclarationDescriptor): Boolean = getDeprecations(descriptor).any { it.deprecationLevel == DeprecationLevelValue.HIDDEN } diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.fir.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.fir.kt similarity index 97% rename from compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.fir.kt rename to compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.fir.kt index bd3f8cb757a..8a3a6a99a2a 100644 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.fir.kt +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.fir.kt @@ -1,3 +1,4 @@ +// LANGUAGE: +StopPropagatingDeprecationThroughOverrides package foo interface WarningDeprecated { diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.kt new file mode 100644 index 00000000000..8f1217de3c0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.kt @@ -0,0 +1,141 @@ +// LANGUAGE: +StopPropagatingDeprecationThroughOverrides +package foo + +interface WarningDeprecated { + @Deprecated("", level = DeprecationLevel.WARNING) + fun f() { + + } +} + +interface ErrorDeprecated { + @Deprecated("", level = DeprecationLevel.ERROR) + fun f() { + + } +} + +interface HiddenDeprecated { + @Deprecated("", level = DeprecationLevel.HIDDEN) + fun f() { + + } +} + +interface NotDeprecated { + fun f() { + + } +} + +open class WE : WarningDeprecated, ErrorDeprecated { + override fun f() { + + } +} + +open class WH : WarningDeprecated, HiddenDeprecated { + override fun f() { + + } +} + +open class EH : ErrorDeprecated, HiddenDeprecated { + override fun f() { + + } +} + +open class NW : WarningDeprecated, NotDeprecated { + override fun f() { + + } +} + +open class NE : ErrorDeprecated, NotDeprecated { + override fun f() { + + } +} + +open class NH : HiddenDeprecated, NotDeprecated { + override fun f() { + + } +} + +open class WEH: WarningDeprecated, ErrorDeprecated, HiddenDeprecated { + override fun f() { + + } +} + +open class NWEH: NotDeprecated, WarningDeprecated, ErrorDeprecated, HiddenDeprecated { + override fun f() { + + } +} + +class WE2: WE() + +class NWE2: WE(), NotDeprecated + +class NWE3: WE(), NotDeprecated { + override fun f() { + } +} + +interface E2: ErrorDeprecated +interface W2: WarningDeprecated + +interface EW2: E2, W2 { + override fun f() { + } +} + +interface HEW2: EW2, HiddenDeprecated { + override fun f() { + } +} + +interface ExplicitError: HEW2 { + @Deprecated("", level = DeprecationLevel.ERROR) + override fun f() { + super.f() + } +} + +fun use( + wd: WarningDeprecated, ed: ErrorDeprecated, hd: HiddenDeprecated, + we: WE, wh: WH, eh: EH, nw: NW, ne: NE, nh: NH, + weh: WEH, nweh: NWEH, + we2: WE2, nwe2: NWE2, nwe3: NWE3, + e2: E2, w2: W2, ew2: EW2, hew2: HEW2, + explicitError: ExplicitError +) { + wd.f() + ed.f() + hd.f() + + we.f() + wh.f() + eh.f() + + nw.f() + ne.f() + nh.f() + + weh.f() + nweh.f() + + we2.f() + nwe2.f() + nwe3.f() + + e2.f() + w2.f() + ew2.f() + hew2.f() + + explicitError.f() +} diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.txt b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.txt rename to compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.txt diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.fir.kt similarity index 88% rename from compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.kt rename to compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.fir.kt index 114ae51efe5..032fdd4cda6 100644 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.kt +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.fir.kt @@ -1,3 +1,4 @@ +// LANGUAGE: -StopPropagatingDeprecationThroughOverrides package foo interface WarningDeprecated { @@ -100,7 +101,7 @@ interface HEW2: EW2, HiddenDeprecated { interface ExplicitError: HEW2 { @Deprecated("", level = DeprecationLevel.ERROR) override fun f() { - super.f() + super.f() } } @@ -114,27 +115,27 @@ fun use( ) { wd.f() ed.f() - hd.f() + hd.f() - we.f() - wh.f() - eh.f() + we.f() + wh.f() + eh.f() nw.f() ne.f() nh.f() - weh.f() + weh.f() nweh.f() - we2.f() + we2.f() nwe2.f() nwe3.f() e2.f() w2.f() - ew2.f() - hew2.f() + ew2.f() + hew2.f() explicitError.f() -} \ No newline at end of file +} diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.kt new file mode 100644 index 00000000000..47f9db76fed --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.kt @@ -0,0 +1,141 @@ +// LANGUAGE: -StopPropagatingDeprecationThroughOverrides +package foo + +interface WarningDeprecated { + @Deprecated("", level = DeprecationLevel.WARNING) + fun f() { + + } +} + +interface ErrorDeprecated { + @Deprecated("", level = DeprecationLevel.ERROR) + fun f() { + + } +} + +interface HiddenDeprecated { + @Deprecated("", level = DeprecationLevel.HIDDEN) + fun f() { + + } +} + +interface NotDeprecated { + fun f() { + + } +} + +open class WE : WarningDeprecated, ErrorDeprecated { + override fun f() { + + } +} + +open class WH : WarningDeprecated, HiddenDeprecated { + override fun f() { + + } +} + +open class EH : ErrorDeprecated, HiddenDeprecated { + override fun f() { + + } +} + +open class NW : WarningDeprecated, NotDeprecated { + override fun f() { + + } +} + +open class NE : ErrorDeprecated, NotDeprecated { + override fun f() { + + } +} + +open class NH : HiddenDeprecated, NotDeprecated { + override fun f() { + + } +} + +open class WEH: WarningDeprecated, ErrorDeprecated, HiddenDeprecated { + override fun f() { + + } +} + +open class NWEH: NotDeprecated, WarningDeprecated, ErrorDeprecated, HiddenDeprecated { + override fun f() { + + } +} + +class WE2: WE() + +class NWE2: WE(), NotDeprecated + +class NWE3: WE(), NotDeprecated { + override fun f() { + } +} + +interface E2: ErrorDeprecated +interface W2: WarningDeprecated + +interface EW2: E2, W2 { + override fun f() { + } +} + +interface HEW2: EW2, HiddenDeprecated { + override fun f() { + } +} + +interface ExplicitError: HEW2 { + @Deprecated("", level = DeprecationLevel.ERROR) + override fun f() { + super.f() + } +} + +fun use( + wd: WarningDeprecated, ed: ErrorDeprecated, hd: HiddenDeprecated, + we: WE, wh: WH, eh: EH, nw: NW, ne: NE, nh: NH, + weh: WEH, nweh: NWEH, + we2: WE2, nwe2: NWE2, nwe3: NWE3, + e2: E2, w2: W2, ew2: EW2, hew2: HEW2, + explicitError: ExplicitError +) { + wd.f() + ed.f() + hd.f() + + we.f() + wh.f() + eh.f() + + nw.f() + ne.f() + nh.f() + + weh.f() + nweh.f() + + we2.f() + nwe2.f() + nwe3.f() + + e2.f() + w2.f() + ew2.f() + hew2.f() + + explicitError.f() +} diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.txt b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.txt new file mode 100644 index 00000000000..1663b51ed9e --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.txt @@ -0,0 +1,156 @@ +package + +package foo { + public fun use(/*0*/ wd: foo.WarningDeprecated, /*1*/ ed: foo.ErrorDeprecated, /*2*/ hd: foo.HiddenDeprecated, /*3*/ we: foo.WE, /*4*/ wh: foo.WH, /*5*/ eh: foo.EH, /*6*/ nw: foo.NW, /*7*/ ne: foo.NE, /*8*/ nh: foo.NH, /*9*/ weh: foo.WEH, /*10*/ nweh: foo.NWEH, /*11*/ we2: foo.WE2, /*12*/ nwe2: foo.NWE2, /*13*/ nwe3: foo.NWE3, /*14*/ e2: foo.E2, /*15*/ w2: foo.W2, /*16*/ ew2: foo.EW2, /*17*/ hew2: foo.HEW2, /*18*/ explicitError: foo.ExplicitError): kotlin.Unit + + public interface E2 : foo.ErrorDeprecated { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "") public open override /*1*/ /*fake_override*/ fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class EH : foo.ErrorDeprecated, foo.HiddenDeprecated { + public constructor EH() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface EW2 : foo.E2, foo.W2 { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface ErrorDeprecated { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "") public open fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface ExplicitError : foo.HEW2 { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "") public open override /*1*/ fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface HEW2 : foo.EW2, foo.HiddenDeprecated { + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface HiddenDeprecated { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "") public open fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class NE : foo.ErrorDeprecated, foo.NotDeprecated { + public constructor NE() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class NH : foo.HiddenDeprecated, foo.NotDeprecated { + public constructor NH() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class NW : foo.WarningDeprecated, foo.NotDeprecated { + public constructor NW() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class NWE2 : foo.WE, foo.NotDeprecated { + public constructor NWE2() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class NWE3 : foo.WE, foo.NotDeprecated { + public constructor NWE3() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class NWEH : foo.NotDeprecated, foo.WarningDeprecated, foo.ErrorDeprecated, foo.HiddenDeprecated { + public constructor NWEH() + public open override /*4*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*4*/ fun f(): kotlin.Unit + public open override /*4*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*4*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface NotDeprecated { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface W2 : foo.WarningDeprecated { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "") public open override /*1*/ /*fake_override*/ fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class WE : foo.WarningDeprecated, foo.ErrorDeprecated { + public constructor WE() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public final class WE2 : foo.WE { + public constructor WE2() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class WEH : foo.WarningDeprecated, foo.ErrorDeprecated, foo.HiddenDeprecated { + public constructor WEH() + public open override /*3*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*3*/ fun f(): kotlin.Unit + public open override /*3*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*3*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class WH : foo.WarningDeprecated, foo.HiddenDeprecated { + public constructor WH() + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ fun f(): kotlin.Unit + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface WarningDeprecated { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + @kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "") public open fun f(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.fir.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.fir.kt similarity index 97% rename from compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.fir.kt rename to compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.fir.kt index ec3699c5eb4..a131152f822 100644 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.fir.kt +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.fir.kt @@ -1,3 +1,4 @@ +// LANGUAGE: +StopPropagatingDeprecationThroughOverrides package foo interface HiddenDeprecated { diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.kt new file mode 100644 index 00000000000..182584ab6f1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.kt @@ -0,0 +1,136 @@ +// LANGUAGE: +StopPropagatingDeprecationThroughOverrides +package foo + +interface HiddenDeprecated { + @Deprecated("", level = DeprecationLevel.HIDDEN) + var p: Int +} + +interface NoDeprecation { + var p: Int +} + + +open class WarningDeprecated { + @Deprecated("", level = DeprecationLevel.WARNING) + open var p: Int = 3 +} + +open class ErrorDeprecated { + @Deprecated("", level = DeprecationLevel.ERROR) + open var p: Int = 3 +} + +open class GetterDeprecated { + open var p: Int = 3 + @Deprecated("") get +} + +open class SetterDeprecated { + open var p: Int = 3 + @Deprecated("") set +} + +class WD: WarningDeprecated() { + override var p: Int + get() = 3 + set(value) {} +} + +class ED: ErrorDeprecated() { + override var p: Int + get() = 3 + set(value) { + } +} + +class GD: GetterDeprecated() { + override var p: Int + get() = 3 + set(value) { + } +} + +class SD: SetterDeprecated() { + override var p: Int + get() = 3 + set(value) { + } +} + +class SDH: SetterDeprecated(), HiddenDeprecated { + override var p: Int + get() = 3 + set(value) { + } +} + +class EDH: ErrorDeprecated(), HiddenDeprecated { + override var p: Int + get() = 3 + set(value) { + } +} + +class NED: ErrorDeprecated(), NoDeprecation { + override var p: Int + get() = 3 + set(value) { + } +} + +class Diff { + @Deprecated("", level = DeprecationLevel.WARNING) + var p: Int + @Deprecated("", level = DeprecationLevel.ERROR) get() = 3 + @Deprecated("", level = DeprecationLevel.HIDDEN) set(value) { + + } +} + +fun use( + warningDeprecated: WarningDeprecated, errorDeprecated: ErrorDeprecated, setterDeprecated: SetterDeprecated, + getterDeprecated: GetterDeprecated, hiddenDeprecated: HiddenDeprecated, + wd: WD, ed: ED, gd: GD, sd: SD, + sdh: SDH, edh: EDH, ned: NED, + diff: Diff +) { + warningDeprecated.p + warningDeprecated.p = 1 + + errorDeprecated.p + errorDeprecated.p = 1 + + getterDeprecated.p + getterDeprecated.p = 1 + + setterDeprecated.p + setterDeprecated.p = 1 + + hiddenDeprecated.p + hiddenDeprecated.p = 1 + + wd.p + wd.p = 1 + + ed.p + ed.p = 1 + + gd.p + gd.p = 1 + + sd.p + sd.p = 1 + + sdh.p + sdh.p = 1 + + edh.p + edh.p = 1 + + ned.p + ned.p = 1 + + diff.p + diff.p = 1 +} diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.txt b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.txt rename to compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.txt diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.fir.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.fir.kt new file mode 100644 index 00000000000..481c792c995 --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.fir.kt @@ -0,0 +1,136 @@ +// LANGUAGE: -StopPropagatingDeprecationThroughOverrides +package foo + +interface HiddenDeprecated { + @Deprecated("", level = DeprecationLevel.HIDDEN) + var p: Int +} + +interface NoDeprecation { + var p: Int +} + + +open class WarningDeprecated { + @Deprecated("", level = DeprecationLevel.WARNING) + open var p: Int = 3 +} + +open class ErrorDeprecated { + @Deprecated("", level = DeprecationLevel.ERROR) + open var p: Int = 3 +} + +open class GetterDeprecated { + open var p: Int = 3 + @Deprecated("") get +} + +open class SetterDeprecated { + open var p: Int = 3 + @Deprecated("") set +} + +class WD: WarningDeprecated() { + override var p: Int + get() = 3 + set(value) {} +} + +class ED: ErrorDeprecated() { + override var p: Int + get() = 3 + set(value) { + } +} + +class GD: GetterDeprecated() { + override var p: Int + get() = 3 + set(value) { + } +} + +class SD: SetterDeprecated() { + override var p: Int + get() = 3 + set(value) { + } +} + +class SDH: SetterDeprecated(), HiddenDeprecated { + override var p: Int + get() = 3 + set(value) { + } +} + +class EDH: ErrorDeprecated(), HiddenDeprecated { + override var p: Int + get() = 3 + set(value) { + } +} + +class NED: ErrorDeprecated(), NoDeprecation { + override var p: Int + get() = 3 + set(value) { + } +} + +class Diff { + @Deprecated("", level = DeprecationLevel.WARNING) + var p: Int + @Deprecated("", level = DeprecationLevel.ERROR) get() = 3 + @Deprecated("", level = DeprecationLevel.HIDDEN) set(value) { + + } +} + +fun use( + warningDeprecated: WarningDeprecated, errorDeprecated: ErrorDeprecated, setterDeprecated: SetterDeprecated, + getterDeprecated: GetterDeprecated, hiddenDeprecated: HiddenDeprecated, + wd: WD, ed: ED, gd: GD, sd: SD, + sdh: SDH, edh: EDH, ned: NED, + diff: Diff +) { + warningDeprecated.p + warningDeprecated.p = 1 + + errorDeprecated.p + errorDeprecated.p = 1 + + getterDeprecated.p + getterDeprecated.p = 1 + + setterDeprecated.p + setterDeprecated.p = 1 + + hiddenDeprecated.p + hiddenDeprecated.p = 1 + + wd.p + wd.p = 1 + + ed.p + ed.p = 1 + + gd.p + gd.p = 1 + + sd.p + sd.p = 1 + + sdh.p + sdh.p = 1 + + edh.p + edh.p = 1 + + ned.p + ned.p = 1 + + diff.p + diff.p = 1 +} diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.kt b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt similarity index 92% rename from compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.kt rename to compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt index c84e382ac12..575ab135398 100644 --- a/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.kt +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt @@ -1,3 +1,4 @@ +// LANGUAGE: -StopPropagatingDeprecationThroughOverrides package foo interface HiddenDeprecated { @@ -31,13 +32,13 @@ open class SetterDeprecated { } class WD: WarningDeprecated() { - override var p: Int + override var p: Int get() = 3 set(value) {} } class ED: ErrorDeprecated() { - override var p: Int + override var p: Int get() = 3 set(value) { } @@ -65,7 +66,7 @@ class SDH: SetterDeprecated(), HiddenDeprecated { } class EDH: ErrorDeprecated(), HiddenDeprecated { - override var p: Int + override var p: Int get() = 3 set(value) { } diff --git a/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.txt b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.txt new file mode 100644 index 00000000000..61c069dcf0c --- /dev/null +++ b/compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.txt @@ -0,0 +1,115 @@ +package + +package foo { + public fun use(/*0*/ warningDeprecated: foo.WarningDeprecated, /*1*/ errorDeprecated: foo.ErrorDeprecated, /*2*/ setterDeprecated: foo.SetterDeprecated, /*3*/ getterDeprecated: foo.GetterDeprecated, /*4*/ hiddenDeprecated: foo.HiddenDeprecated, /*5*/ wd: foo.WD, /*6*/ ed: foo.ED, /*7*/ gd: foo.GD, /*8*/ sd: foo.SD, /*9*/ sdh: foo.SDH, /*10*/ edh: foo.EDH, /*11*/ ned: foo.NED, /*12*/ diff: foo.Diff): kotlin.Unit + + public final class Diff { + public constructor Diff() + @kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "") @get:kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "") @set:kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "") public final var p: kotlin.Int + 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 final class ED : foo.ErrorDeprecated { + public constructor ED() + public open override /*1*/ var p: kotlin.Int + 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 final class EDH : foo.ErrorDeprecated, foo.HiddenDeprecated { + public constructor EDH() + public open override /*2*/ var p: kotlin.Int + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class ErrorDeprecated { + public constructor ErrorDeprecated() + @kotlin.Deprecated(level = DeprecationLevel.ERROR, message = "") public open var p: kotlin.Int + 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 final class GD : foo.GetterDeprecated { + public constructor GD() + public open override /*1*/ var p: kotlin.Int + 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 open class GetterDeprecated { + public constructor GetterDeprecated() + @get:kotlin.Deprecated(message = "") public open var p: kotlin.Int + 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 interface HiddenDeprecated { + @kotlin.Deprecated(level = DeprecationLevel.HIDDEN, message = "") public abstract var p: kotlin.Int + 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 final class NED : foo.ErrorDeprecated, foo.NoDeprecation { + public constructor NED() + public open override /*2*/ var p: kotlin.Int + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface NoDeprecation { + public abstract var p: kotlin.Int + 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 final class SD : foo.SetterDeprecated { + public constructor SD() + public open override /*1*/ var p: kotlin.Int + 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 final class SDH : foo.SetterDeprecated, foo.HiddenDeprecated { + public constructor SDH() + public open override /*2*/ var p: kotlin.Int + public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String + } + + public open class SetterDeprecated { + public constructor SetterDeprecated() + @set:kotlin.Deprecated(message = "") public open var p: kotlin.Int + 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 final class WD : foo.WarningDeprecated { + public constructor WD() + public open override /*1*/ var p: kotlin.Int + 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 open class WarningDeprecated { + public constructor WarningDeprecated() + @kotlin.Deprecated(level = DeprecationLevel.WARNING, message = "") public open var p: kotlin.Int + 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 + } +} diff --git a/compiler/testData/diagnostics/tests/j+k/deprecations/forMixedOverride.kt b/compiler/testData/diagnostics/tests/j+k/deprecations/forMixedOverride.kt index f809ed9f310..b7898c89865 100644 --- a/compiler/testData/diagnostics/tests/j+k/deprecations/forMixedOverride.kt +++ b/compiler/testData/diagnostics/tests/j+k/deprecations/forMixedOverride.kt @@ -16,7 +16,7 @@ interface WithDeprecation { } class A : J(), WithDeprecation { - override fun foo() {} + override fun foo() {} } fun main() { diff --git a/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt b/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt index 121f3206a7d..85693f73abf 100644 --- a/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt +++ b/compiler/testData/diagnostics/tests/resolve/HiddenDeclarations.kt @@ -58,13 +58,13 @@ interface I { } class X : I { - override fun foo1() { + override fun foo1() { } } class B : A("") { // still can override it - override fun memberFun() { + override fun memberFun() { super.memberFun() // but cannot call super :) } } diff --git a/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt index a9b6f81495b..d1d87cd1e57 100644 --- a/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt +++ b/compiler/testData/diagnostics/tests/testWithModifiedMockJdk/notConsideredMethod.kt @@ -3,7 +3,7 @@ interface A : MutableCollection { // Override of deprecated function could be marked as deprecated too - override fun nonExistingMethod(x: String) = "" + override fun nonExistingMethod(x: String) = "" } fun foo(x: MutableCollection, y: Collection, z: A) { diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java index 9e37bce1055..de0f9f70f7e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/DiagnosticTestGenerated.java @@ -8604,15 +8604,27 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } @Test - @TestMetadata("deprecatedInheritance.kt") - public void testDeprecatedInheritance() throws Exception { - runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.kt"); + @TestMetadata("deprecatedInheritance_after.kt") + public void testDeprecatedInheritance_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.kt"); } @Test - @TestMetadata("deprecatedPropertyInheritance.kt") - public void testDeprecatedPropertyInheritance() throws Exception { - runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.kt"); + @TestMetadata("deprecatedInheritance_before.kt") + public void testDeprecatedInheritance_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.kt"); + } + + @Test + @TestMetadata("deprecatedPropertyInheritance_after.kt") + public void testDeprecatedPropertyInheritance_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.kt"); + } + + @Test + @TestMetadata("deprecatedPropertyInheritance_before.kt") + public void testDeprecatedPropertyInheritance_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt"); } @Test diff --git a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt index 6ab91228a5f..4a40ec20ec6 100644 --- a/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/config/LanguageVersionSettings.kt @@ -230,6 +230,7 @@ enum class LanguageFeature( ProhibitSimplificationOfNonTrivialConstBooleanExpressions(KOTLIN_1_7), SafeCallsAreAlwaysNullable(KOTLIN_1_7), ApproximateIntegerLiteralTypesInReceiverPosition(KOTLIN_1_7), + StopPropagatingDeprecationThroughOverrides(KOTLIN_1_7), // Temporarily disabled, see KT-27084/KT-22379 SoundSmartcastFromLoopConditionForLoopAssignedVariables(sinceVersion = null, kind = BUG_FIX), diff --git a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java index d23d08dd538..46c8bf15aca 100644 --- a/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java +++ b/idea/idea-frontend-fir/idea-fir-low-level-api/tests/org/jetbrains/kotlin/idea/fir/low/level/api/diagnostic/compiler/based/DiagnosisCompilerTestFE10TestdataTestGenerated.java @@ -8598,15 +8598,27 @@ public class DiagnosisCompilerTestFE10TestdataTestGenerated extends AbstractDiag } @Test - @TestMetadata("deprecatedInheritance.kt") - public void testDeprecatedInheritance() throws Exception { - runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance.kt"); + @TestMetadata("deprecatedInheritance_after.kt") + public void testDeprecatedInheritance_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_after.kt"); } @Test - @TestMetadata("deprecatedPropertyInheritance.kt") - public void testDeprecatedPropertyInheritance() throws Exception { - runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance.kt"); + @TestMetadata("deprecatedInheritance_before.kt") + public void testDeprecatedInheritance_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedInheritance_before.kt"); + } + + @Test + @TestMetadata("deprecatedPropertyInheritance_after.kt") + public void testDeprecatedPropertyInheritance_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_after.kt"); + } + + @Test + @TestMetadata("deprecatedPropertyInheritance_before.kt") + public void testDeprecatedPropertyInheritance_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/deprecated/deprecatedPropertyInheritance_before.kt"); } @Test