[FIR] Implement suppressing diagnostics with @Suppress

This commit is contained in:
Dmitriy Novozhilov
2021-02-01 18:34:03 +03:00
parent 459a2886a0
commit ebced14db2
20 changed files with 376 additions and 43 deletions
@@ -3103,6 +3103,39 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/suppress")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Suppress extends AbstractLazyBodyIsNotTouchedTilContractsPhaseTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInSuppress() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/suppress"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@TestMetadata("allWarnings.kt")
public void testAllWarnings() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/allWarnings.kt");
}
@TestMetadata("multipleWarnings.kt")
public void testMultipleWarnings() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/multipleWarnings.kt");
}
@TestMetadata("singleError.kt")
public void testSingleError() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt");
}
@TestMetadata("singleWarning.kt")
public void testSingleWarning() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt");
}
}
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/types")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -0,0 +1,10 @@
FILE: allWarnings.kt
@R|kotlin/Suppress|(vararg(String(warnings))) public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
public final fun foo(): R|kotlin/Unit| {
}
}
@@ -0,0 +1,6 @@
// WITH_EXTENDED_CHECKERS
@Suppress("warnings")
public class A {
final fun foo() {}
}
@@ -0,0 +1,10 @@
FILE: multipleWarnings.kt
@R|kotlin/Suppress|(vararg(String(REDUNDANT_VISIBILITY_MODIFIER))) public final class A : R|kotlin/Any| {
public constructor(): R|A| {
super<R|kotlin/Any|>()
}
@R|kotlin/Suppress|(vararg(String(REDUNDANT_MODALITY_MODIFIER))) public final fun foo(): R|kotlin/Unit| {
}
}
@@ -0,0 +1,7 @@
// WITH_EXTENDED_CHECKERS
@Suppress("REDUNDANT_VISIBILITY_MODIFIER")
public class A {
@Suppress("REDUNDANT_MODALITY_MODIFIER")
public final fun foo() {}
}
@@ -0,0 +1,6 @@
FILE: singleError.kt
public final fun foo(x: R|kotlin/String|): R|kotlin/Unit| {
}
@R|kotlin/Suppress|(vararg(String(INAPPLICABLE_CANDIDATE))) public final fun bar(): R|kotlin/Unit| {
<Inapplicable(INAPPLICABLE): /foo>#(Int(10))
}
@@ -0,0 +1,6 @@
fun foo(x: String) {}
@Suppress("INAPPLICABLE_CANDIDATE")
fun bar() {
foo(10)
}
@@ -0,0 +1,3 @@
FILE: singleWarning.kt
@R|kotlin/Suppress|(vararg(String(REDUNDANT_VISIBILITY_MODIFIER))) public final fun foo(): R|kotlin/Unit| {
}
@@ -0,0 +1,4 @@
// WITH_EXTENDED_CHECKERS
@Suppress("REDUNDANT_VISIBILITY_MODIFIER")
public fun foo() {}
@@ -3474,6 +3474,40 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
}
}
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/suppress")
@TestDataPath("$PROJECT_ROOT")
public class Suppress extends AbstractFirDiagnosticTest {
@Test
public void testAllFilesPresentInSuppress() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/suppress"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("allWarnings.kt")
public void testAllWarnings() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/allWarnings.kt");
}
@Test
@TestMetadata("multipleWarnings.kt")
public void testMultipleWarnings() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/multipleWarnings.kt");
}
@Test
@TestMetadata("singleError.kt")
public void testSingleError() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt");
}
@Test
@TestMetadata("singleWarning.kt")
public void testSingleWarning() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt");
}
}
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/types")
@TestDataPath("$PROJECT_ROOT")
@@ -3520,6 +3520,41 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
}
}
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/suppress")
@TestDataPath("$PROJECT_ROOT")
@Execution(ExecutionMode.SAME_THREAD)
public class Suppress extends AbstractFirDiagnosticsWithLightTreeTest {
@Test
public void testAllFilesPresentInSuppress() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/analysis-tests/testData/resolve/suppress"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
}
@Test
@TestMetadata("allWarnings.kt")
public void testAllWarnings() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/allWarnings.kt");
}
@Test
@TestMetadata("multipleWarnings.kt")
public void testMultipleWarnings() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/multipleWarnings.kt");
}
@Test
@TestMetadata("singleError.kt")
public void testSingleError() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleError.kt");
}
@Test
@TestMetadata("singleWarning.kt")
public void testSingleWarning() throws Exception {
runTest("compiler/fir/analysis-tests/testData/resolve/suppress/singleWarning.kt");
}
}
@Nested
@TestMetadata("compiler/fir/analysis-tests/testData/resolve/types")
@TestDataPath("$PROJECT_ROOT")