From 179b267d9f0b023a292bbfa30fdfb3c9ed0da707 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Wed, 20 Jul 2022 14:46:12 +0200 Subject: [PATCH] K2: add test with some samples of diagnostic suppression --- ...nosisCompilerFirTestdataTestGenerated.java | 6 ++++ ...TouchedTilContractsPhaseTestGenerated.java | 5 +++ .../resolve/suppress/withSuppression.fir.txt | 36 +++++++++++++++++++ .../resolve/suppress/withSuppression.kt | 20 +++++++++++ .../runners/FirDiagnosticTestGenerated.java | 6 ++++ ...DiagnosticsWithLightTreeTestGenerated.java | 6 ++++ 6 files changed, 79 insertions(+) create mode 100644 compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.fir.txt create mode 100644 compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java index aa4b1ee6e33..1dea77a7c88 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/diagnostic/compiler/based/DiagnosisCompilerFirTestdataTestGenerated.java @@ -4210,6 +4210,12 @@ public class DiagnosisCompilerFirTestdataTestGenerated extends AbstractDiagnosis public void testSingleWarning() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt"); } + + @Test + @TestMetadata("withSuppression.kt") + public void testWithSuppression() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java index 62928b68795..05de33f92e4 100644 --- a/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java +++ b/compiler/fir/analysis-tests/legacy-fir-tests/tests-gen/org/jetbrains/kotlin/fir/LazyBodyIsNotTouchedTilContractsPhaseTestGenerated.java @@ -3758,6 +3758,11 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract public void testSingleWarning() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt"); } + + @TestMetadata("withSuppression.kt") + public void testWithSuppression() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt"); + } } @TestMetadata("compiler/fir/analysis-tests/testData/resolve/types") diff --git a/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.fir.txt b/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.fir.txt new file mode 100644 index 00000000000..f99e8a22006 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.fir.txt @@ -0,0 +1,36 @@ +FILE: withSuppression.kt + public final const val x: R|kotlin/String| = String(123) + @R|kotlin/Suppress|(names = vararg(String(CONST_VAL_WITH_GETTER))) public get(): R|kotlin/String| { + ^ F|/x| + } + public final val y: R|kotlin/String| = String(789) + public get(): R|kotlin/String| + public final const val z: R|kotlin/String| = @R|kotlin/Suppress|(names = vararg(String(CONST_VAL_WITH_NON_CONST_INITIALIZER))) R|/y| + public get(): R|kotlin/String| + @R|kotlin/annotation/Target|(allowedTargets = vararg(Q|kotlin/annotation/AnnotationTarget|.R|kotlin/annotation/AnnotationTarget.TYPE|)) public final annotation class Ann : R|kotlin/Annotation| { + public constructor(): R|Ann| { + super() + } + + } + public final fun foo(): R|@R|kotlin/Suppress|(names = vararg(String(REPEATED_ANNOTATION))) @R|Ann|() @R|Ann|() kotlin/Int| { + ^foo Int(42) + } + public final typealias Alias = R|@R|kotlin/Suppress|(names = vararg(String(TYPEALIAS_SHOULD_EXPAND_TO_CLASS))) T| + public abstract interface A : R|kotlin/Any| { + } + public abstract interface B : R|@R|kotlin/Suppress|(names = vararg(String(SUPERTYPE_INITIALIZED_IN_INTERFACE))) A| { + } + public final data class D : R|kotlin/Any| { + @R|kotlin/Suppress|(names = vararg(String(DATA_CLASS_VARARG_PARAMETER))) public constructor(vararg x: R|kotlin/Array|): R|D| { + super() + } + + public final val x: R|kotlin/Array| = R|/x| + public get(): R|kotlin/Array| + + public final operator fun component1(): R|kotlin/String| + + public final fun copy(x: R|kotlin/String| = this@R|/D|.R|/D.x|): R|D| + + } diff --git a/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt b/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt new file mode 100644 index 00000000000..ce429d1f164 --- /dev/null +++ b/compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt @@ -0,0 +1,20 @@ +const val x = "123" + @Suppress("CONST_VAL_WITH_GETTER") + get() = field + +val y = "789" + +const val z = @Suppress("CONST_VAL_WITH_NON_CONST_INITIALIZER") y + +@Target(AnnotationTarget.TYPE) +annotation class Ann + +fun foo(): @Suppress("REPEATED_ANNOTATION") @Ann @Ann Int = 42 + +typealias Alias = @Suppress("TYPEALIAS_SHOULD_EXPAND_TO_CLASS") T + +interface A + +interface B : @Suppress("SUPERTYPE_INITIALIZED_IN_INTERFACE") A() + +data class D @Suppress("DATA_CLASS_VARARG_PARAMETER") constructor(vararg val x: String) diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java index 8041bf9559d..fe3251530ce 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticTestGenerated.java @@ -4210,6 +4210,12 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest { public void testSingleWarning() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt"); } + + @Test + @TestMetadata("withSuppression.kt") + public void testWithSuppression() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt"); + } } @Nested diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java index aa8f42f3731..7de7d01283d 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirDiagnosticsWithLightTreeTestGenerated.java @@ -4210,6 +4210,12 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos public void testSingleWarning() throws Exception { runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt"); } + + @Test + @TestMetadata("withSuppression.kt") + public void testWithSuppression() throws Exception { + runTest("compiler/fir/analysis-tests/testData/resolve/suppress/withSuppression.kt"); + } } @Nested