diff --git a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt index f78248ab098..1a458ce7e22 100644 --- a/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt +++ b/compiler/fir/checkers/src/org/jetbrains/kotlin/fir/analysis/diagnostics/coneDiagnosticToFirDiagnostic.kt @@ -35,7 +35,7 @@ import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability import org.jetbrains.kotlin.resolve.calls.tower.isSuccess import org.jetbrains.kotlin.types.EmptyIntersectionTypeKind import org.jetbrains.kotlin.utils.addIfNotNull -import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstance +import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull import org.jetbrains.kotlin.utils.addToStdlib.runIf private fun ConeDiagnostic.toKtDiagnostic( @@ -68,14 +68,12 @@ private fun ConeDiagnostic.toKtDiagnostic( is ConeAmbiguityError -> when { applicability.isSuccess -> FirErrors.OVERLOAD_RESOLUTION_AMBIGUITY.createOn(source, this.candidates.map { it.symbol }) applicability == CandidateApplicability.UNSAFE_CALL -> { - val candidate = candidates.first { it.applicability == CandidateApplicability.UNSAFE_CALL } - val unsafeCall = candidate.diagnostics.firstIsInstance() + val (unsafeCall, candidate) = candidates.firstNotNullOf { it.diagnostics.firstIsInstanceOrNull()?.to(it) } mapUnsafeCallError(candidate, unsafeCall, source, qualifiedAccessSource) } applicability == CandidateApplicability.UNSTABLE_SMARTCAST -> { - val unstableSmartcast = - this.candidates.first { it.applicability == CandidateApplicability.UNSTABLE_SMARTCAST }.diagnostics.firstIsInstance() + val unstableSmartcast = this.candidates.firstNotNullOf { it.diagnostics.firstIsInstanceOrNull() } FirErrors.SMARTCAST_IMPOSSIBLE.createOn( unstableSmartcast.argument.source, unstableSmartcast.targetType, diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java index c75c08bc762..ba56cbac2fe 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirLightTreeBlackBoxCodegenTestGenerated.java @@ -50204,6 +50204,22 @@ public class FirLightTreeBlackBoxCodegenTestGenerated extends AbstractFirLightTr } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java index 1365f2e577e..fd5117b9a8e 100644 --- a/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java +++ b/compiler/fir/fir2ir/tests-gen/org/jetbrains/kotlin/test/runners/codegen/FirPsiBlackBoxCodegenTestGenerated.java @@ -50204,6 +50204,22 @@ public class FirPsiBlackBoxCodegenTestGenerated extends AbstractFirPsiBlackBoxCo } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt index d0f2688eaae..a95cdae7c4c 100644 --- a/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt +++ b/compiler/fir/resolve/src/org/jetbrains/kotlin/fir/FirCallResolver.kt @@ -165,30 +165,52 @@ class FirCallResolver( val result = towerResolver.runResolver(info, resolutionContext, collector) val bestCandidates = result.bestCandidates() - fun chooseMostSpecific(): Set { - val onSuperReference = (explicitReceiver as? FirQualifiedAccessExpression)?.calleeReference is FirSuperReference - return conflictResolver.chooseMaximallySpecificCandidates( - bestCandidates, discriminateAbstracts = onSuperReference - ) - } - - var reducedCandidates = if (!result.currentApplicability.isSuccess) { - val distinctApplicabilities = bestCandidates.mapTo(mutableSetOf()) { it.currentApplicability } - //if all candidates have the same kind on inApplicability - try to choose the most specific one - if (distinctApplicabilities.size == 1 && distinctApplicabilities.single() > CandidateApplicability.INAPPLICABLE) { - chooseMostSpecific() - } else { - bestCandidates.toSet() - } - } else { - chooseMostSpecific() - } - + var reducedCandidates = reduceCandidates(bestCandidates, explicitReceiver, resolutionContext, result.currentApplicability.isSuccess) reducedCandidates = overloadByLambdaReturnTypeResolver.reduceCandidates(qualifiedAccess, bestCandidates, reducedCandidates) return ResolutionResult(info, result.currentApplicability, reducedCandidates) } + private fun reduceCandidates( + candidates: List, + explicitReceiver: FirExpression?, + resolutionContext: ResolutionContext, + isSuccess: Boolean, + ): Set { + fun chooseMostSpecific(list: List): Set { + val onSuperReference = (explicitReceiver as? FirQualifiedAccessExpression)?.calleeReference is FirSuperReference + return conflictResolver.chooseMaximallySpecificCandidates(list, discriminateAbstracts = onSuperReference) + } + + if (isSuccess) { + return chooseMostSpecific(candidates) + } + + val singleApplicability = candidates.mapTo(mutableSetOf()) { it.currentApplicability }.singleOrNull() + + if (singleApplicability == null || singleApplicability <= CandidateApplicability.INAPPLICABLE) { + return candidates.toSet() + } + + // If all candidates have the same kind on inapplicability - try to choose the most specific one + if (candidates.size > 1) { + // We have multiple candidates with the same inapplicability. We want to select the "least bad" candidates. + + // First, fully process all of them and group them by their worst applicability. + val groupedByDiagnosticCount = candidates.groupBy { + components.resolutionStageRunner.fullyProcessCandidate(it, resolutionContext) + it.diagnostics.minOf(ResolutionDiagnostic::applicability) + } + + // Then, select the group with the best worst applicability. + groupedByDiagnosticCount.maxBy { it.key }.let { + return chooseMostSpecific(it.value) + } + } + + return chooseMostSpecific(candidates) + } + fun resolveVariableAccessAndSelectCandidate( qualifiedAccess: FirQualifiedAccessExpression, isUsedAsReceiver: Boolean, diff --git a/compiler/testData/codegen/box/suppressions/suppressInvisible.kt b/compiler/testData/codegen/box/suppressions/suppressInvisible.kt new file mode 100644 index 00000000000..6fcaeed7784 --- /dev/null +++ b/compiler/testData/codegen/box/suppressions/suppressInvisible.kt @@ -0,0 +1,11 @@ +// MODULE: a +// FILE: a.kt + +internal fun foo(s: String) = "FAIL" +internal fun foo(s: String, x: Any) = "OK" + +// MODULE: b(a) +// FILE: box.kt + +@Suppress("INVISIBLE_MEMBER", "INVISIBLE_REFERENCE") +fun box() = foo("", Any()) diff --git a/compiler/testData/diagnostics/tests/overload/onlyPrivateOverloadsDiagnostic.fir.kt b/compiler/testData/diagnostics/tests/overload/onlyPrivateOverloadsDiagnostic.fir.kt index 71cd8529a56..d87a774aa43 100644 --- a/compiler/testData/diagnostics/tests/overload/onlyPrivateOverloadsDiagnostic.fir.kt +++ b/compiler/testData/diagnostics/tests/overload/onlyPrivateOverloadsDiagnostic.fir.kt @@ -6,7 +6,7 @@ class A { } fun test(a: A) { - a.foo(3) + a.foo(3) a.foo() } diff --git a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt index e88739944bb..f51170a2d92 100644 --- a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt +++ b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/constructors.fir.kt @@ -7,7 +7,7 @@ open class A protected constructor(x: Int) { } fun foo() { - A() + A() A(1.0) } diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.fir.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.fir.kt index dafb82b5d3b..70ec9199f0d 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.fir.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.fir.kt @@ -9,11 +9,11 @@ open class MyClass private constructor(val x: Int) { typealias MyAlias = MyClass -val test1 = MyAlias(1) -val test1a = MyClass(1) +val test1 = MyAlias(1) +val test1a = MyClass(1) -val test2 = MyAlias("") -val test2a = MyClass("") +val test2 = MyAlias("") +val test2a = MyClass("") val test3 = MyAlias(1.0) val test3a = MyClass(1.0) diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java index 4a7771a602d..10f400ec94c 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/BlackBoxCodegenTestGenerated.java @@ -47648,6 +47648,22 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java index bfc24955645..20c820a905e 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenTestGenerated.java @@ -50204,6 +50204,22 @@ public class IrBlackBoxCodegenTestGenerated extends AbstractIrBlackBoxCodegenTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java index 70209a29bf3..a3dc99647e7 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/codegen/IrBlackBoxCodegenWithIrInlinerTestGenerated.java @@ -50204,6 +50204,22 @@ public class IrBlackBoxCodegenWithIrInlinerTestGenerated extends AbstractIrBlack } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM_IR, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java index 3ea758be8c4..0cfd8237f9a 100644 --- a/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/LightAnalysisModeTestGenerated.java @@ -38647,6 +38647,24 @@ public class LightAnalysisModeTestGenerated extends AbstractLightAnalysisModeTes } } + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Suppressions extends AbstractLightAnalysisModeTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, TargetBackend.JVM, testDataFilePath); + } + + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JVM, true); + } + + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.fir.kt index fcd1f08e00b..b52e0374f24 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/10.fir.kt @@ -345,22 +345,22 @@ class case_14_class { if (!funWithReturnsTrueAndInvertCondition(value_1 is Float? && value_1 != null && value_2 != null && o.prop_1 != null)) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (funWithReturnsFalse(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null)) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (funWithReturnsNotNull(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null) == null) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (funWithReturnsNull(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null) != null) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } } } @@ -414,26 +414,26 @@ class case_17_class { if (contracts.case_17_1(value_1, value_2, o.prop_1, this.prop_1)) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) - println(this.prop_1.plus(3)) + println(o.prop_1.plus(3)) + println(this.prop_1.plus(3)) } if (contracts.case_17_2(value_1, value_2, o.prop_1, this.prop_1)) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) - println(this.prop_1.plus(3)) + println(o.prop_1.plus(3)) + println(this.prop_1.plus(3)) } if (contracts.case_17_3(value_1, value_2, o.prop_1, this.prop_1) == null) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) - println(this.prop_1.plus(3)) + println(o.prop_1.plus(3)) + println(this.prop_1.plus(3)) } if (contracts.case_17_4(value_1, value_2, o.prop_1, this.prop_1) != null) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) - println(this.prop_1.plus(3)) + println(o.prop_1.plus(3)) + println(this.prop_1.plus(3)) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/2.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/2.fir.kt index df3a2fab230..5aa6d852dea 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/2.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/2.fir.kt @@ -37,7 +37,7 @@ class case_5_class { funWithReturns(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null) println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } } @@ -130,22 +130,22 @@ class case_10_class { if (funWithReturnsTrue(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null)) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (!funWithReturnsFalse(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null)) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (funWithReturnsNotNull(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null) != null) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (funWithReturnsNull(value_1 !is Float? || value_1 == null || value_2 == null || o.prop_1 == null || this.prop_1 == null) == null) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } } } diff --git a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/3.fir.kt b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/3.fir.kt index 3c93cacc432..899059c12ab 100644 --- a/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/3.fir.kt +++ b/compiler/tests-spec/testData/diagnostics/notLinked/contracts/analysis/smartcasts/neg/3.fir.kt @@ -105,7 +105,7 @@ class case_3_class { contracts.case_3(value_1, value_2, o.prop_1, this.prop_1) println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } } @@ -158,22 +158,22 @@ class case_6_class { if (contracts.case_6_1(value_1, value_2, o.prop_1, this.prop_1)) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (!contracts.case_6_2(value_1, value_2, o.prop_1, this.prop_1)) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (contracts.case_6_3(value_1, value_2, o.prop_1, this.prop_1) == null) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } if (contracts.case_6_4(value_1, value_2, o.prop_1, this.prop_1) != null) { println(value_1.dec()) println(value_2?.toByte()) - println(o.prop_1.plus(3)) + println(o.prop_1.plus(3)) } } } diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java index 0a37cd11bda..f487b9e4987 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/JsCodegenBoxTestGenerated.java @@ -35530,6 +35530,22 @@ public class JsCodegenBoxTestGenerated extends AbstractJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java index d87b97ee47c..a7ff3878a0c 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/fir/FirJsCodegenBoxTestGenerated.java @@ -35872,6 +35872,22 @@ public class FirJsCodegenBoxTestGenerated extends AbstractFirJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java index c1faf432503..9e53aa29d9d 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsCodegenBoxTestGenerated.java @@ -35872,6 +35872,22 @@ public class IrJsCodegenBoxTestGenerated extends AbstractIrJsCodegenBoxTest { } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java index 64bd90ab2d7..d71fb99b3a1 100644 --- a/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java +++ b/js/js.tests/tests-gen/org/jetbrains/kotlin/js/test/ir/IrJsES6CodegenBoxTestGenerated.java @@ -35872,6 +35872,22 @@ public class IrJsES6CodegenBoxTestGenerated extends AbstractIrJsES6CodegenBoxTes } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.JS_IR_ES6, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java index a424caf279d..1155afd7e11 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestGenerated.java @@ -39966,6 +39966,26 @@ public class FirNativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTe } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegenK2") + @Tag("firCodegen") + @UseExtTestCaseGroupProvider() + @FirPipeline() + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java index 79fa09c74d1..e439095ece8 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/FirNativeCodegenBoxTestNoPLGenerated.java @@ -40948,6 +40948,28 @@ public class FirNativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenB } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegenK2") + @Tag("firCodegen") + @UseExtTestCaseGroupProvider() + @FirPipeline() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java index 28532765b53..389581f209d 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestGenerated.java @@ -39475,6 +39475,25 @@ public class NativeCodegenBoxTestGenerated extends AbstractNativeCodegenBoxTest } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @Tag("k1Codegen") + @UseExtTestCaseGroupProvider() + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java index 7655cdb2a88..ddf93917861 100644 --- a/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java +++ b/native/native.tests/tests-gen/org/jetbrains/kotlin/konan/blackboxtest/NativeCodegenBoxTestNoPLGenerated.java @@ -40457,6 +40457,27 @@ public class NativeCodegenBoxTestNoPLGenerated extends AbstractNativeCodegenBoxT } } + @Nested + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + @Tag("codegen") + @Tag("k1Codegen") + @UseExtTestCaseGroupProvider() + @UsePartialLinkage(mode = Mode.DISABLED) + @Tag("no-partial-linkage-may-be-skipped") + public class Suppressions { + @Test + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^(.+)\\.kt$"), null, TargetBackend.NATIVE, true); + } + + @Test + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @Nested @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") diff --git a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java index 6a1bf8be1ce..f656d4dd6d2 100644 --- a/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java +++ b/wasm/wasm.tests/tests-gen/org/jetbrains/kotlin/wasm/test/IrCodegenBoxWasmTestGenerated.java @@ -32032,6 +32032,24 @@ public class IrCodegenBoxWasmTestGenerated extends AbstractIrCodegenBoxWasmTest } } + @TestMetadata("compiler/testData/codegen/box/suppressions") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class Suppressions extends AbstractIrCodegenBoxWasmTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest0(this::doTest, TargetBackend.WASM, testDataFilePath); + } + + public void testAllFilesPresentInSuppressions() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/box/suppressions"), Pattern.compile("^([^_](.+))\\.kt$"), null, TargetBackend.WASM, true); + } + + @TestMetadata("suppressInvisible.kt") + public void testSuppressInvisible() throws Exception { + runTest("compiler/testData/codegen/box/suppressions/suppressInvisible.kt"); + } + } + @TestMetadata("compiler/testData/codegen/box/suspendConversion") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)