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 89e5ac41730..247769af5ae 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 @@ -24326,12 +24326,24 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia runTest("compiler/testData/diagnostics/tests/overload/kt1998.kt"); } + @Test + @TestMetadata("kt22004.kt") + public void testKt22004() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt22004.kt"); + } + @Test @TestMetadata("kt2493.kt") public void testKt2493() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/kt2493.kt"); } + @Test + @TestMetadata("kt61168WithFix.kt") + public void testKt61168WithFix() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt61168WithFix.kt"); + } + @Test @TestMetadata("kt7068.kt") public void testKt7068() throws Exception { @@ -24415,6 +24427,76 @@ public class DiagnosticCompilerTestFE10TestdataTestGenerated extends AbstractDia public void testUnsubstitutedJavaGenetics() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/UnsubstitutedJavaGenetics.kt"); } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated") + @TestDataPath("$PROJECT_ROOT") + public class NoConflictingOverloadsWithDeprecated { + @Test + public void testAllFilesPresentInNoConflictingOverloadsWithDeprecated() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInPackage.kt") + public void testConflictingOverloadsFunsDifferentReturnInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsGenericFunctions.kt") + public void testConflictingOverloadsGenericFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalExtFunsInPackage.kt") + public void testConflictingOverloadsIdenticalExtFunsInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") + public void testConflictingOverloadsIdenticalValsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsValsDifferentTypeInClass.kt") + public void testConflictingOverloadsValsDifferentTypeInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.kt"); + } + + @Test + @TestMetadata("ConstructorVsFunOverload.kt") + public void testConstructorVsFunOverload() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.kt"); + } + + @Test + @TestMetadata("LocalFunctions.kt") + public void testLocalFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/LocalFunctions.kt"); + } + + @Test + @TestMetadata("TypeParameterMultipleBounds.kt") + public void testTypeParameterMultipleBounds() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.kt"); + } + } } @Nested 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 7f483f470a4..adb1a30508c 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 @@ -24326,12 +24326,24 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated runTest("compiler/testData/diagnostics/tests/overload/kt1998.kt"); } + @Test + @TestMetadata("kt22004.kt") + public void testKt22004() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt22004.kt"); + } + @Test @TestMetadata("kt2493.kt") public void testKt2493() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/kt2493.kt"); } + @Test + @TestMetadata("kt61168WithFix.kt") + public void testKt61168WithFix() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt61168WithFix.kt"); + } + @Test @TestMetadata("kt7068.kt") public void testKt7068() throws Exception { @@ -24415,6 +24427,76 @@ public class LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated public void testUnsubstitutedJavaGenetics() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/UnsubstitutedJavaGenetics.kt"); } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated") + @TestDataPath("$PROJECT_ROOT") + public class NoConflictingOverloadsWithDeprecated { + @Test + public void testAllFilesPresentInNoConflictingOverloadsWithDeprecated() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInPackage.kt") + public void testConflictingOverloadsFunsDifferentReturnInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsGenericFunctions.kt") + public void testConflictingOverloadsGenericFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalExtFunsInPackage.kt") + public void testConflictingOverloadsIdenticalExtFunsInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") + public void testConflictingOverloadsIdenticalValsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsValsDifferentTypeInClass.kt") + public void testConflictingOverloadsValsDifferentTypeInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.kt"); + } + + @Test + @TestMetadata("ConstructorVsFunOverload.kt") + public void testConstructorVsFunOverload() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.kt"); + } + + @Test + @TestMetadata("LocalFunctions.kt") + public void testLocalFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/LocalFunctions.kt"); + } + + @Test + @TestMetadata("TypeParameterMultipleBounds.kt") + public void testTypeParameterMultipleBounds() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.kt"); + } + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java index 2a2c5a9f626..629a70a746b 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirLightTreeOldFrontendDiagnosticsTestGenerated.java @@ -24326,12 +24326,24 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir runTest("compiler/testData/diagnostics/tests/overload/kt1998.kt"); } + @Test + @TestMetadata("kt22004.kt") + public void testKt22004() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt22004.kt"); + } + @Test @TestMetadata("kt2493.kt") public void testKt2493() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/kt2493.kt"); } + @Test + @TestMetadata("kt61168WithFix.kt") + public void testKt61168WithFix() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt61168WithFix.kt"); + } + @Test @TestMetadata("kt7068.kt") public void testKt7068() throws Exception { @@ -24415,6 +24427,76 @@ public class FirLightTreeOldFrontendDiagnosticsTestGenerated extends AbstractFir public void testUnsubstitutedJavaGenetics() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/UnsubstitutedJavaGenetics.kt"); } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated") + @TestDataPath("$PROJECT_ROOT") + public class NoConflictingOverloadsWithDeprecated { + @Test + public void testAllFilesPresentInNoConflictingOverloadsWithDeprecated() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInPackage.kt") + public void testConflictingOverloadsFunsDifferentReturnInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsGenericFunctions.kt") + public void testConflictingOverloadsGenericFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalExtFunsInPackage.kt") + public void testConflictingOverloadsIdenticalExtFunsInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") + public void testConflictingOverloadsIdenticalValsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsValsDifferentTypeInClass.kt") + public void testConflictingOverloadsValsDifferentTypeInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.kt"); + } + + @Test + @TestMetadata("ConstructorVsFunOverload.kt") + public void testConstructorVsFunOverload() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.kt"); + } + + @Test + @TestMetadata("LocalFunctions.kt") + public void testLocalFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/LocalFunctions.kt"); + } + + @Test + @TestMetadata("TypeParameterMultipleBounds.kt") + public void testTypeParameterMultipleBounds() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.kt"); + } + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java index 9663262c530..93c3774c9dd 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendDiagnosticsTestGenerated.java @@ -24332,12 +24332,24 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia runTest("compiler/testData/diagnostics/tests/overload/kt1998.kt"); } + @Test + @TestMetadata("kt22004.kt") + public void testKt22004() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt22004.kt"); + } + @Test @TestMetadata("kt2493.kt") public void testKt2493() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/kt2493.kt"); } + @Test + @TestMetadata("kt61168WithFix.kt") + public void testKt61168WithFix() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt61168WithFix.kt"); + } + @Test @TestMetadata("kt7068.kt") public void testKt7068() throws Exception { @@ -24421,6 +24433,76 @@ public class FirPsiOldFrontendDiagnosticsTestGenerated extends AbstractFirPsiDia public void testUnsubstitutedJavaGenetics() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/UnsubstitutedJavaGenetics.kt"); } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated") + @TestDataPath("$PROJECT_ROOT") + public class NoConflictingOverloadsWithDeprecated { + @Test + public void testAllFilesPresentInNoConflictingOverloadsWithDeprecated() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "multiplatform"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInPackage.kt") + public void testConflictingOverloadsFunsDifferentReturnInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsGenericFunctions.kt") + public void testConflictingOverloadsGenericFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalExtFunsInPackage.kt") + public void testConflictingOverloadsIdenticalExtFunsInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") + public void testConflictingOverloadsIdenticalValsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsValsDifferentTypeInClass.kt") + public void testConflictingOverloadsValsDifferentTypeInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.kt"); + } + + @Test + @TestMetadata("ConstructorVsFunOverload.kt") + public void testConstructorVsFunOverload() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.kt"); + } + + @Test + @TestMetadata("LocalFunctions.kt") + public void testLocalFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/LocalFunctions.kt"); + } + + @Test + @TestMetadata("TypeParameterMultipleBounds.kt") + public void testTypeParameterMultipleBounds() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.kt"); + } + } } @Nested diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt index 03d70a31977..40f83044790 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/checkers/FirConflictsHelpers.kt @@ -219,7 +219,7 @@ private fun > FirDeclarationCollector.collect( val conflicts = SmartSet.create>() for (otherDeclaration in it) { - if (otherDeclaration != declaration && !isOverloadable(declaration, otherDeclaration, session)) { + if (otherDeclaration != declaration && !areNonConflictingCallables(declaration, otherDeclaration, session)) { conflicts.add(otherDeclaration) declarationConflictingSymbols.getOrPut(otherDeclaration) { SmartSet.create() }.add(declaration) } @@ -390,7 +390,7 @@ private fun FirDeclarationCollector>.collectTopLevelConflict( conflicting is FirMemberDeclaration && !session.visibilityChecker.isVisible(conflicting, session, containingFile, emptyList(), dispatchReceiver = null) ) return - if (isOverloadable(declaration, conflictingSymbol, session)) return + if (areNonConflictingCallables(declaration, conflictingSymbol, session)) return declarationConflictingSymbols.getOrPut(declaration) { SmartSet.create() }.add(conflictingSymbol) } @@ -417,7 +417,7 @@ private fun areCompatibleMainFunctions( && declaration1.representsMainFunctionAllowingConflictingOverloads(session) && declaration2.representsMainFunctionAllowingConflictingOverloads(session) -private fun isOverloadable( +private fun areNonConflictingCallables( declaration: FirBasedSymbol<*>, conflicting: FirBasedSymbol<*>, session: FirSession, @@ -428,6 +428,12 @@ private fun isOverloadable( val conflictingIsLowPriority = hasLowPriorityAnnotation(conflicting.annotations) if (declarationIsLowPriority != conflictingIsLowPriority) return true + val declarationIsHidden = declaration.isDeprecationLevelHidden(session.languageVersionSettings) + if (declarationIsHidden) return true + + val conflictingIsHidden = conflicting.isDeprecationLevelHidden(session.languageVersionSettings) + if (conflictingIsHidden) return true + return declaration is FirCallableSymbol<*> && conflicting is FirCallableSymbol<*> && session.declarationOverloadabilityHelper.isOverloadable(declaration, conflicting) diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/declarations/deprecationUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/declarations/deprecationUtils.kt index a68ba68e75e..dfa406b288a 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/declarations/deprecationUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/declarations/deprecationUtils.kt @@ -310,6 +310,13 @@ private fun List.extractDeprecationAnnotationInfoPerUseSite( } } + +fun FirBasedSymbol<*>.isDeprecationLevelHidden(languageVersionSettings: LanguageVersionSettings): Boolean = + when (this) { + is FirCallableSymbol<*> -> getDeprecation(languageVersionSettings)?.all?.deprecationLevel == DeprecationLevelValue.HIDDEN + else -> false + } + private object IsHiddenEverywhereBesideSuperCalls : FirDeclarationDataKey() var FirCallableDeclaration.isHiddenEverywhereBesideSuperCalls: Boolean? by FirDeclarationDataRegistry.data( diff --git a/compiler/testData/diagnostics/tests/overload/kt22004.fir.kt b/compiler/testData/diagnostics/tests/overload/kt22004.fir.kt new file mode 100644 index 00000000000..e7c164e993e --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/kt22004.fir.kt @@ -0,0 +1,10 @@ +// ISSUE: KT-22004 + +class A() { + fun b() { + } + + @Deprecated("test", level = DeprecationLevel.HIDDEN) + fun b() { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/kt22004.kt b/compiler/testData/diagnostics/tests/overload/kt22004.kt new file mode 100644 index 00000000000..06de0d8228c --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/kt22004.kt @@ -0,0 +1,10 @@ +// ISSUE: KT-22004 + +class A() { + fun b() { + } + + @Deprecated("test", level = DeprecationLevel.HIDDEN) + fun b() { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/kt61168WithFix.fir.kt b/compiler/testData/diagnostics/tests/overload/kt61168WithFix.fir.kt new file mode 100644 index 00000000000..5985f831955 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/kt61168WithFix.fir.kt @@ -0,0 +1,7 @@ +// ISSUE: KT-61168 + +class A() { +} + +@Deprecated("A", level = DeprecationLevel.HIDDEN) +fun A() = A() diff --git a/compiler/testData/diagnostics/tests/overload/kt61168WithFix.kt b/compiler/testData/diagnostics/tests/overload/kt61168WithFix.kt new file mode 100644 index 00000000000..e4fe204544c --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/kt61168WithFix.kt @@ -0,0 +1,7 @@ +// ISSUE: KT-61168 + +class A() { +} + +@Deprecated("A", level = DeprecationLevel.HIDDEN) +fun A() = A() diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt new file mode 100644 index 00000000000..c8eabd47541 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.fir.kt @@ -0,0 +1,7 @@ +class A { + fun a(a: Int): Int = 0 + + @Deprecated("a", level = DeprecationLevel.HIDDEN) + fun a(a: Int) { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.kt new file mode 100644 index 00000000000..ed163a13f12 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.kt @@ -0,0 +1,7 @@ +class A { + fun a(a: Int): Int = 0 + + @Deprecated("a", level = DeprecationLevel.HIDDEN) + fun a(a: Int) { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt new file mode 100644 index 00000000000..a4ad3295d83 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.fir.kt @@ -0,0 +1,8 @@ +package qwertyuiop + +fun c(s: String) { +} + +@Deprecated("c", level = DeprecationLevel.HIDDEN) +fun c(s: String) { +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.kt new file mode 100644 index 00000000000..f42e1dc3eb8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.kt @@ -0,0 +1,8 @@ +package qwertyuiop + +fun c(s: String) { +} + +@Deprecated("c", level = DeprecationLevel.HIDDEN) +fun c(s: String) { +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.fir.kt new file mode 100644 index 00000000000..8a20eab2a83 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.fir.kt @@ -0,0 +1,37 @@ +fun test1(x: List) = x +@Deprecated("test1", level = DeprecationLevel.HIDDEN) +fun test1(x: List) = x + +fun List.test1a() {} +@Deprecated("test2", level = DeprecationLevel.HIDDEN) +fun List.test1a() {} + +fun test2(x: List) = x +fun test2(x: List) = x + +fun List.test2a() {} +fun List.test2a() {} + +fun test3(x: List) = x +fun test3(x: List) = x + +fun List.test3a() {} +fun List.test3a() {} + +fun test4(x: Map) = x +fun test4(x: Map) = x + +fun Map.test4a() {} +fun Map.test4a() {} + +class Inv + +fun test5(x: Inv) = x +@Deprecated("test5", level = DeprecationLevel.HIDDEN) +fun test5(x: Inv) = x + +fun test6(x: Array) = x +fun test6(x: Array) = x + +fun test7(x: Inv) = x +fun Inv.test7() {} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.kt new file mode 100644 index 00000000000..8e1b1316555 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.kt @@ -0,0 +1,37 @@ +fun test1(x: List) = x +@Deprecated("test1", level = DeprecationLevel.HIDDEN) +fun test1(x: List) = x + +fun List.test1a() {} +@Deprecated("test2", level = DeprecationLevel.HIDDEN) +fun List.test1a() {} + +fun test2(x: List) = x +fun test2(x: List) = x + +fun List.test2a() {} +fun List.test2a() {} + +fun test3(x: List) = x +fun test3(x: List) = x + +fun List.test3a() {} +fun List.test3a() {} + +fun test4(x: Map) = x +fun test4(x: Map) = x + +fun Map.test4a() {} +fun Map.test4a() {} + +class Inv + +fun test5(x: Inv) = x +@Deprecated("test5", level = DeprecationLevel.HIDDEN) +fun test5(x: Inv) = x + +fun test6(x: Array) = x +fun test6(x: Array) = x + +fun test7(x: Inv) = x +fun Inv.test7() {} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt new file mode 100644 index 00000000000..08753d2691e --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.fir.kt @@ -0,0 +1,6 @@ +package extensionFunctions + +fun Int.qwe(a: Float) = 1 + +@Deprecated("qwe", level = DeprecationLevel.HIDDEN) +fun Int.qwe(a: Float) = 2 diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.kt new file mode 100644 index 00000000000..a9e909f1bcc --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.kt @@ -0,0 +1,6 @@ +package extensionFunctions + +fun Int.qwe(a: Float) = 1 + +@Deprecated("qwe", level = DeprecationLevel.HIDDEN) +fun Int.qwe(a: Float) = 2 diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.fir.kt new file mode 100644 index 00000000000..68c5b239f13 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.fir.kt @@ -0,0 +1,8 @@ +class A() { + fun b() { + } + + @Deprecated("b", level = DeprecationLevel.HIDDEN) + fun b() { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.kt new file mode 100644 index 00000000000..4274b35b362 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.kt @@ -0,0 +1,8 @@ +class A() { + fun b() { + } + + @Deprecated("b", level = DeprecationLevel.HIDDEN) + fun b() { + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.fir.kt new file mode 100644 index 00000000000..affd3a5a0f0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.fir.kt @@ -0,0 +1,5 @@ +class Aaa() { + val a = 1 + @Deprecated("a", level = DeprecationLevel.HIDDEN) + val a = 1 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.kt new file mode 100644 index 00000000000..235b1630bf2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.kt @@ -0,0 +1,5 @@ +class Aaa() { + val a = 1 + @Deprecated("a", level = DeprecationLevel.HIDDEN) + val a = 1 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.fir.kt new file mode 100644 index 00000000000..268154e83fc --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.fir.kt @@ -0,0 +1,5 @@ +class Aaa() { + val a = 1 + @Deprecated("a", level = DeprecationLevel.HIDDEN) + val a = "" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.kt new file mode 100644 index 00000000000..cee529be50e --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.kt @@ -0,0 +1,5 @@ +class Aaa() { + val a = 1 + @Deprecated("a", level = DeprecationLevel.HIDDEN) + val a = "" +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.fir.kt new file mode 100644 index 00000000000..8c85184177a --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.fir.kt @@ -0,0 +1,57 @@ +// constructor vs. fun overload + +// FILE: J.java +package constructorVsFun; + +public class J { + public J(String s) {} +} + +// FILE: G.java +package constructorVsFun; + +public class G { + @kotlin.Deprecated("G", level = DeprecationLevel.HIDDEN) + public G(String s) {} +} + +// FILE: test.kt +package constructorVsFun + +class a() { } + +@Deprecated("a", level = DeprecationLevel.HIDDEN) +fun a() = 1 + +class b @Deprecated("b", level = DeprecationLevel.HIDDEN) constructor() { } + +fun b() = 2 + +class Tram { + @Deprecated("f", level = DeprecationLevel.HIDDEN) + fun f() { } + + class f() { } +} + +class Yvayva { + companion object { + @Deprecated("fghj", level = DeprecationLevel.HIDDEN) + fun fghj() { } + + class fghj() { } + } +} + +class Rtyu { + fun ololo() { } + + companion object { + class ololo() { } + } +} + +@Deprecated("J", level = DeprecationLevel.HIDDEN) +fun J(s: String) { } + +fun G(s: String) { } diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.kt new file mode 100644 index 00000000000..7bcdbe40bc4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.kt @@ -0,0 +1,57 @@ +// constructor vs. fun overload + +// FILE: J.java +package constructorVsFun; + +public class J { + public J(String s) {} +} + +// FILE: G.java +package constructorVsFun; + +public class G { + @kotlin.Deprecated("G", level = DeprecationLevel.HIDDEN) + public G(String s) {} +} + +// FILE: test.kt +package constructorVsFun + +class a() { } + +@Deprecated("a", level = DeprecationLevel.HIDDEN) +fun a() = 1 + +class b @Deprecated("b", level = DeprecationLevel.HIDDEN) constructor() { } + +fun b() = 2 + +class Tram { + @Deprecated("f", level = DeprecationLevel.HIDDEN) + fun f() { } + + class f() { } +} + +class Yvayva { + companion object { + @Deprecated("fghj", level = DeprecationLevel.HIDDEN) + fun fghj() { } + + class fghj() { } + } +} + +class Rtyu { + fun ololo() { } + + companion object { + class ololo() { } + } +} + +@Deprecated("J", level = DeprecationLevel.HIDDEN) +fun J(s: String) { } + +fun G(s: String) { } diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/LocalFunctions.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/LocalFunctions.kt new file mode 100644 index 00000000000..6e45f6a33fc --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/LocalFunctions.kt @@ -0,0 +1,265 @@ +// FIR_IDENTICAL + +fun test() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + + fun local() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + } +} + +class Test { + init { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + } + + fun test() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + } + + val property: Any get() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + + return 0 + } +} + +val property: Any get() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + + return 0 +} + +object Object { + fun test() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + } + + val property: Any get() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + + return 0 + } +} + +val obj = object { + fun test() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + } + + val property: Any get() { + fun test1() {} + @Deprecated("test1", level = DeprecationLevel.HIDDEN) + fun test1() {} + + fun Any.test2() {} + fun test2(x: Any) = x + + fun Any.test3() {} + @Deprecated("test3", level = DeprecationLevel.HIDDEN) + fun Any.test3() {} + + fun test4(): Int = 0 + @Deprecated("test4", level = DeprecationLevel.HIDDEN) + fun test4(): String = "" + + class Test5(val x: Int) { + constructor(): this(0) + } + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5() {} + @Deprecated("Test5", level = DeprecationLevel.HIDDEN) + fun Test5(x: Int) = x + + return 0 + } +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.fir.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.fir.kt new file mode 100644 index 00000000000..db41f8d75c3 --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.fir.kt @@ -0,0 +1,17 @@ +import java.io.Serializable + +interface Test1 { + fun foo(t: T) where T : Cloneable, T : Serializable + @Deprecated("foo", level = DeprecationLevel.HIDDEN) + fun foo(t: T) where T : Serializable, T : Cloneable +} + + +interface I1 +interface I2 : I1 + +interface Test2 { + fun foo(t: T) where T : I1, T : I2 + @Deprecated("foo", level = DeprecationLevel.HIDDEN) + fun foo(t: T) where T : I2, T : I1 +} diff --git a/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.kt b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.kt new file mode 100644 index 00000000000..a85a6a2444f --- /dev/null +++ b/compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.kt @@ -0,0 +1,17 @@ +import java.io.Serializable + +interface Test1 { + fun foo(t: T) where T : Cloneable, T : Serializable + @Deprecated("foo", level = DeprecationLevel.HIDDEN) + fun foo(t: T) where T : Serializable, T : Cloneable +} + + +interface I1 +interface I2 : I1 + +interface Test2 { + fun foo(t: T) where T : I1, T : I2 + @Deprecated("foo", level = DeprecationLevel.HIDDEN) + fun foo(t: T) where T : I2, T : I1 +} 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 b1b2fb4b8e1..7a4b397f984 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 @@ -26184,12 +26184,24 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { runTest("compiler/testData/diagnostics/tests/overload/kt1998.kt"); } + @Test + @TestMetadata("kt22004.kt") + public void testKt22004() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt22004.kt"); + } + @Test @TestMetadata("kt2493.kt") public void testKt2493() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/kt2493.kt"); } + @Test + @TestMetadata("kt61168WithFix.kt") + public void testKt61168WithFix() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/kt61168WithFix.kt"); + } + @Test @TestMetadata("kt7068.kt") public void testKt7068() throws Exception { @@ -26273,6 +26285,76 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest { public void testUnsubstitutedJavaGenetics() throws Exception { runTest("compiler/testData/diagnostics/tests/overload/UnsubstitutedJavaGenetics.kt"); } + + @Nested + @TestMetadata("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated") + @TestDataPath("$PROJECT_ROOT") + public class NoConflictingOverloadsWithDeprecated { + @Test + public void testAllFilesPresentInNoConflictingOverloadsWithDeprecated() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInClass.kt") + public void testConflictingOverloadsFunsDifferentReturnInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsFunsDifferentReturnInPackage.kt") + public void testConflictingOverloadsFunsDifferentReturnInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsFunsDifferentReturnInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsGenericFunctions.kt") + public void testConflictingOverloadsGenericFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsGenericFunctions.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalExtFunsInPackage.kt") + public void testConflictingOverloadsIdenticalExtFunsInPackage() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalExtFunsInPackage.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalFunsInClass.kt") + public void testConflictingOverloadsIdenticalFunsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalFunsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsIdenticalValsInClass.kt") + public void testConflictingOverloadsIdenticalValsInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsIdenticalValsInClass.kt"); + } + + @Test + @TestMetadata("ConflictingOverloadsValsDifferentTypeInClass.kt") + public void testConflictingOverloadsValsDifferentTypeInClass() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConflictingOverloadsValsDifferentTypeInClass.kt"); + } + + @Test + @TestMetadata("ConstructorVsFunOverload.kt") + public void testConstructorVsFunOverload() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/ConstructorVsFunOverload.kt"); + } + + @Test + @TestMetadata("LocalFunctions.kt") + public void testLocalFunctions() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/LocalFunctions.kt"); + } + + @Test + @TestMetadata("TypeParameterMultipleBounds.kt") + public void testTypeParameterMultipleBounds() throws Exception { + runTest("compiler/testData/diagnostics/tests/overload/noConflictingOverloadsWithDeprecated/TypeParameterMultipleBounds.kt"); + } + } } @Nested