diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java index 2fd0e4c5245..b04fee82708 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosticCompilerTestFE10TestdataTestGenerated.java @@ -25540,6 +25540,22 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation") + @TestDataPath("$PROJECT_ROOT") + public class DeprecatedAnnotation { + @Test + public void testAllFilesPresentInDeprecatedAnnotation() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("hidden.kt") + public void testHidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/enum") @TestDataPath("$PROJECT_ROOT") diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java index fc449beba05..02d6e86a9da 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated.java @@ -25540,6 +25540,22 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation") + @TestDataPath("$PROJECT_ROOT") + public class DeprecatedAnnotation { + @Test + public void testAllFilesPresentInDeprecatedAnnotation() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation"), Pattern.compile("^(.+)\\.(kt|kts)$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("hidden.kt") + public void testHidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/enum") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java index 31d534805db..44dc31d1f6a 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated.java @@ -1387,6 +1387,22 @@ public class FirOldFrontendMPPDiagnosticsWithLightTreeTestGenerated extends Abst } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation") + @TestDataPath("$PROJECT_ROOT") + public class DeprecatedAnnotation { + @Test + public void testAllFilesPresentInDeprecatedAnnotation() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("hidden.kt") + public void testHidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/enum") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java index 1a3c3a1d3f3..73ffd20d789 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirOldFrontendMPPDiagnosticsWithPsiTestGenerated.java @@ -1387,6 +1387,22 @@ public class FirOldFrontendMPPDiagnosticsWithPsiTestGenerated extends AbstractFi } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation") + @TestDataPath("$PROJECT_ROOT") + public class DeprecatedAnnotation { + @Test + public void testAllFilesPresentInDeprecatedAnnotation() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("hidden.kt") + public void testHidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/enum") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt index 30a3ac85254..135d99bf6ba 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/resolve/calls/ResolutionStages.kt @@ -9,10 +9,7 @@ import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.descriptors.Modality import org.jetbrains.kotlin.fir.FirElement import org.jetbrains.kotlin.fir.declarations.* -import org.jetbrains.kotlin.fir.declarations.utils.isFun -import org.jetbrains.kotlin.fir.declarations.utils.isInfix -import org.jetbrains.kotlin.fir.declarations.utils.isOperator -import org.jetbrains.kotlin.fir.declarations.utils.modality +import org.jetbrains.kotlin.fir.declarations.utils.* import org.jetbrains.kotlin.fir.expressions.* import org.jetbrains.kotlin.fir.languageVersionSettings import org.jetbrains.kotlin.fir.matchingParameterFunctionType @@ -760,6 +757,8 @@ internal object CheckCallModifiers : CheckerStage() { internal object CheckHiddenDeclaration : ResolutionStage() { override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) { val symbol = candidate.symbol as? FirCallableSymbol<*> ?: return + /** Actual declarations are checked by [FirDeprecationChecker] */ + if (symbol.isActual) return val deprecation = symbol.getDeprecation(context.session, callInfo.callSite) if (deprecation?.deprecationLevel == DeprecationLevelValue.HIDDEN || isHiddenForThisCallSite(symbol, callInfo, candidate)) { sink.yieldDiagnostic(HiddenCandidate) diff --git a/compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.fir.kt b/compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.fir.kt new file mode 100644 index 00000000000..da3e38a2018 --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.fir.kt @@ -0,0 +1,32 @@ +// MODULE: m1-common +// FILE: common.kt + +expect class A() + +expect class B() + +expect fun foo(test: String) + +fun test() { + A() + B() + foo("") +} + +// MODULE: m2-jvm()()(m1-common) +// FILE: jvm.kt + +@Deprecated("", level = DeprecationLevel.HIDDEN) +actual class A + +actual class B @Deprecated("", level = DeprecationLevel.HIDDEN) actual constructor(){} + +@Deprecated("", level = DeprecationLevel.HIDDEN) +actual fun foo(test: String) { +} + +fun main() { + A() + B() + foo("") +} diff --git a/compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.kt b/compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.kt new file mode 100644 index 00000000000..3bffb119acd --- /dev/null +++ b/compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.kt @@ -0,0 +1,32 @@ +// MODULE: m1-common +// FILE: common.kt + +expect class A() + +expect class B() + +expect fun foo(test: String) + +fun test() { + A() + B() + foo("") +} + +// MODULE: m2-jvm()()(m1-common) +// FILE: jvm.kt + +@Deprecated("", level = DeprecationLevel.HIDDEN) +actual class A + +actual class B @Deprecated("", level = DeprecationLevel.HIDDEN) actual constructor(){} + +@Deprecated("", level = DeprecationLevel.HIDDEN) +actual fun foo(test: String) { +} + +fun main() { + A() + B() + foo("") +} 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 e2dca6272dc..56c6a538497 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 @@ -25540,6 +25540,22 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { } } + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation") + @TestDataPath("$PROJECT_ROOT") + public class DeprecatedAnnotation { + @Test + public void testAllFilesPresentInDeprecatedAnnotation() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("hidden.kt") + public void testHidden() throws Exception { + runTest("compiler/testData/diagnostics/tests/multiplatform/deprecatedAnnotation/hidden.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/tests/multiplatform/enum") @TestDataPath("$PROJECT_ROOT")