From 8a560d2629f95dce3761e86999c1cd09b569a427 Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Tue, 2 Jan 2024 13:57:48 +0100 Subject: [PATCH] FE tests: don't render text of disabled diagnostics --- .../inference/builderInference/kt47986Default.diag.txt | 9 --------- .../builderInference/kt47986Disabled.diag.txt | 10 +--------- .../inference/builderInference/kt47986_2.diag.txt | 9 --------- .../inference/builderInference/kt47986_3.diag.txt | 9 --------- .../tests/inference/builderInference/kt51464.diag.txt | 9 --------- .../inference/emptyIntersectionTypes/kt45461.diag.txt | 4 +--- .../emptyIntersectionTypes/kt45461_11.diag.txt | 3 --- .../inference/emptyIntersectionTypes/kt45461_11.kt | 1 - .../emptyIntersectionTypes/kt45461_12.diag.txt | 3 --- .../emptyIntersectionTypes/kt45461_2.diag.txt | 3 --- .../emptyIntersectionTypes/kt45461_5.diag.txt | 4 +--- .../inference/emptyIntersectionTypes/kt48765.diag.txt | 6 ------ .../inference/emptyIntersectionTypes/kt48935.diag.txt | 3 --- .../selectFromCovariantAndContravariantTypes.diag.txt | 10 +--------- .../diagnostics/tests/javac/LambdaNonGeneric.diag.txt | 6 ------ .../diagnostics/testsWithStdLib/labelClashes.diag.txt | 10 +--------- .../labelClashesWithContextReceivers.diag.txt | 6 ------ .../classic/handlers/DiagnosticMessagesTextHandler.kt | 9 ++++++++- 18 files changed, 13 insertions(+), 101 deletions(-) delete mode 100644 compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_11.diag.txt diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/kt47986Default.diag.txt b/compiler/testData/diagnostics/tests/inference/builderInference/kt47986Default.diag.txt index efae3c025fe..2b5596f4c33 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/kt47986Default.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/kt47986Default.diag.txt @@ -1,12 +1,3 @@ -/kt47986Default.kt:4:18: warning: parameter 'builderAction' is never used -fun buildFoo(builderAction: Foo.() -> Unit): Foo = Foo() - ^ -/kt47986Default.kt:6:20: warning: parameter 'x' is never used -fun Foo.bar(x: Int = 1) {} - ^ -/kt47986Default.kt:9:9: warning: variable 'x' is never used - val x = buildFoo { - ^ /kt47986Default.kt:9:13: warning: type parameter for a type argument K can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases. val x = buildFoo { ^ diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/kt47986Disabled.diag.txt b/compiler/testData/diagnostics/tests/inference/builderInference/kt47986Disabled.diag.txt index 026f85a9c3d..6435912d7c2 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/kt47986Disabled.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/kt47986Disabled.diag.txt @@ -1,12 +1,4 @@ -/kt47986Disabled.kt:5:18: warning: parameter 'builderAction' is never used -fun buildFoo(builderAction: Foo.() -> Unit): Foo = Foo() - ^ -/kt47986Disabled.kt:7:20: warning: parameter 'x' is never used -fun Foo.bar(x: Int = 1) {} - ^ -/kt47986Disabled.kt:10:9: warning: variable 'x' is never used - val x = buildFoo { - ^ /kt47986Disabled.kt:10:13: warning: type parameter for a type argument K can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases. val x = buildFoo { ^ + diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/kt47986_2.diag.txt b/compiler/testData/diagnostics/tests/inference/builderInference/kt47986_2.diag.txt index adb1163f3ef..013f5c8c28a 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/kt47986_2.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/kt47986_2.diag.txt @@ -1,13 +1,4 @@ -/kt47986_2.kt:4:18: warning: parameter 'builderAction' is never used -fun buildFoo(builderAction: Foo.() -> Unit): Foo = Foo() - ^ -/kt47986_2.kt:11:9: warning: variable 'x' is never used - val x = buildFoo { // can't infer - ^ /kt47986_2.kt:11:13: warning: type parameter for a type argument K can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases. val x = buildFoo { // can't infer ^ -/kt47986_2.kt:12:13: warning: variable 'y' is never used - val y = id(::bar) - ^ diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/kt47986_3.diag.txt b/compiler/testData/diagnostics/tests/inference/builderInference/kt47986_3.diag.txt index a6a639c0ae6..e0c8f57c7df 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/kt47986_3.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/kt47986_3.diag.txt @@ -1,12 +1,3 @@ -/kt47986_3.kt:4:18: warning: parameter 'builderAction' is never used -fun buildFoo(builderAction: Foo.() -> Unit): Foo = Foo() - ^ -/kt47986_3.kt:6:26: warning: parameter 'x' is never used -fun Foo.bar(x: Int = 1) {} - ^ -/kt47986_3.kt:9:9: warning: variable 'x' is never used - val x = buildFoo { - ^ /kt47986_3.kt:9:13: warning: type parameter for a type argument K can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases. val x = buildFoo { ^ diff --git a/compiler/testData/diagnostics/tests/inference/builderInference/kt51464.diag.txt b/compiler/testData/diagnostics/tests/inference/builderInference/kt51464.diag.txt index 7eb788d4c71..ec8f6c7021d 100644 --- a/compiler/testData/diagnostics/tests/inference/builderInference/kt51464.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/builderInference/kt51464.diag.txt @@ -1,12 +1,3 @@ -/kt51464.kt:2:16: warning: parameter 'value' is never used -fun flowOf(value: T): Flow = TODO() - ^ -/kt51464.kt:8:30: warning: parameter 'transform' is never used -fun Flow.transform(transform: FlowCollector.(T) -> Unit): Flow = TODO() - ^ -/kt51464.kt:11:20: warning: parameter 'collector' is never used - fun doEmit(collector: FlowCollector) {} - ^ /kt51464.kt:12:15: warning: type parameter for a type argument R can't be inferred into declared upper bounds. Please provide any use-site type information. It will become an error in future releases. flowOf(1).transform { doEmit(this) } ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461.diag.txt index eaa9979ed21..6190e8ae5c2 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461.diag.txt @@ -1,6 +1,4 @@ -/kt45461.kt:7:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ /kt45461.kt:12:19: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, Int (multiple incompatible classes). This will become an error in Kotlin 2.0 Bar().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 ^ + diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_11.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_11.diag.txt deleted file mode 100644 index 27a8145ebd8..00000000000 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_11.diag.txt +++ /dev/null @@ -1,3 +0,0 @@ -/kt45461_11.kt:6:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_11.kt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_11.kt index 819fc73f0c4..22660a947a6 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_11.kt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_11.kt @@ -1,5 +1,4 @@ // FIR_IDENTICAL -// RENDER_DIAGNOSTICS_FULL_TEXT class Foo class Bar { diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_12.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_12.diag.txt index be373608aee..04a4bfc1e25 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_12.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_12.diag.txt @@ -1,6 +1,3 @@ -/kt45461_12.kt:7:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ /kt45461_12.kt:14:19: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, K (multiple incompatible classes: String, Number). This will become an error in Kotlin 2.0 Bar().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_2.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_2.diag.txt index 9c711b1ba6f..72de14b46cd 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_2.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_2.diag.txt @@ -1,6 +1,3 @@ -/kt45461_2.kt:7:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ /kt45461_2.kt:10:10: warning: 'Int' is a final type, and thus a value of the type parameter is predetermined fun main() { ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_5.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_5.diag.txt index ac1958b7595..fb86fe9c348 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_5.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt45461_5.diag.txt @@ -1,6 +1,4 @@ -/kt45461_5.kt:7:25: warning: parameter 'foo' is never used - fun takeFoo(foo: Foo) {} - ^ /kt45461_5.kt:12:19: warning: type argument for a type parameter S can't be inferred because it has incompatible upper bounds: String, K (multiple incompatible classes: String, Number). This will become an error in Kotlin 2.0 Bar().takeFoo(foo) // error in 1.3.72, no error in 1.4.31 ^ + diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt48765.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt48765.diag.txt index efa3c21c3c8..c000fa04666 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt48765.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt48765.diag.txt @@ -1,9 +1,3 @@ -/kt48765.kt:6:44: warning: parameter 'x1' is never used - fun > foo(x1: T2, x2: T1) {} - ^ -/kt48765.kt:6:52: warning: parameter 'x2' is never used - fun > foo(x1: T2, x2: T1) {} - ^ /kt48765.kt:10:13: warning: type argument for a type parameter T can't be inferred because it has incompatible upper bounds: String, Number (multiple incompatible classes). This will become an error in Kotlin 2.0 B().foo(x, foo()) ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt48935.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt48935.diag.txt index cd9d8450834..5dea8d76fca 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt48935.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/kt48935.diag.txt @@ -1,6 +1,3 @@ -/kt48935.kt:7:35: warning: parameter 'func' is never used -fun exampleGenericFunction(func: V) where T: Base, V: (T) -> Unit { - ^ /kt48935.kt:13:5: warning: type argument for a type parameter T has possible incompatible upper bounds: Base, DoesNotImplementBase (final class and interface) exampleGenericFunction(func) // expected this to be a compilation error as the T: Base constraint should not be satisfied ^ diff --git a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/selectFromCovariantAndContravariantTypes.diag.txt b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/selectFromCovariantAndContravariantTypes.diag.txt index cc3f151eca0..941a69be451 100644 --- a/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/selectFromCovariantAndContravariantTypes.diag.txt +++ b/compiler/testData/diagnostics/tests/inference/emptyIntersectionTypes/selectFromCovariantAndContravariantTypes.diag.txt @@ -1,12 +1,4 @@ -/selectFromCovariantAndContravariantTypes.kt:12:22: warning: parameter 'y' is never used -fun select(x: K, y: K): K = x - ^ -/selectFromCovariantAndContravariantTypes.kt:13:19: warning: parameter 'x' is never used -fun genericIn(x: In) {} - ^ -/selectFromCovariantAndContravariantTypes.kt:14:20: warning: parameter 'x' is never used -fun genericOut(x: Out) {} - ^ /selectFromCovariantAndContravariantTypes.kt:17:5: warning: type argument for a type parameter V can't be inferred because it has incompatible upper bounds: A, B (multiple incompatible classes). This will become an error in Kotlin 2.0 genericIn(select(a, b)) ^ + diff --git a/compiler/testData/diagnostics/tests/javac/LambdaNonGeneric.diag.txt b/compiler/testData/diagnostics/tests/javac/LambdaNonGeneric.diag.txt index 357808ba569..0fc930fbdb9 100644 --- a/compiler/testData/diagnostics/tests/javac/LambdaNonGeneric.diag.txt +++ b/compiler/testData/diagnostics/tests/javac/LambdaNonGeneric.diag.txt @@ -1,12 +1,6 @@ // -- Module: -- // -- Module: -- -/m2.kt:14:9: warning: parameter 'f' is never used -fun foo(f: (Some, String) -> Unit) {} - ^ -/m2.kt:15:9: warning: parameter 'f' is never used -fun bar(f: (Some) -> Unit) {} - ^ // -- Module: -- /m3.kt:24:17: error: unresolved reference: Some diff --git a/compiler/testData/diagnostics/testsWithStdLib/labelClashes.diag.txt b/compiler/testData/diagnostics/testsWithStdLib/labelClashes.diag.txt index 080018e1fd8..ccfda0778d6 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/labelClashes.diag.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/labelClashes.diag.txt @@ -4,21 +4,13 @@ /labelClashes.kt:11:13: warning: this label is now resolved to 'function bar' but soon it will be resolved to the closest 'anonymous function'. Please consider introducing or changing explicit label name this@bar.inc() ^ -/labelClashes.kt:15:9: warning: parameter 'f' is never used -fun foo(f: with.() -> Unit) {} - ^ /labelClashes.kt:20:17: warning: this label is now resolved to 'class with' but soon it will be resolved to the closest 'anonymous function'. Please consider introducing or changing explicit label name this@with.foo() ^ /labelClashes.kt:24:17: warning: this label is now resolved to 'class with' but soon it will be resolved to the closest 'anonymous function'. Please consider introducing or changing explicit label name this@with.foo() ^ -/labelClashes.kt:37:9: warning: the expression is unused - this@TypedThis - ^ /labelClashes.kt:37:13: warning: this label is now resolved to 'class TypedThis' but soon it will be resolved to the closest 'function baz extension receiver'. Please consider introducing or changing explicit label name this@TypedThis ^ -/labelClashes.kt:41:9: warning: the expression is unused - this@TypedThis - ^ + diff --git a/compiler/testData/diagnostics/testsWithStdLib/labelClashesWithContextReceivers.diag.txt b/compiler/testData/diagnostics/testsWithStdLib/labelClashesWithContextReceivers.diag.txt index bdaa3110e2a..0ce0154ba4f 100644 --- a/compiler/testData/diagnostics/testsWithStdLib/labelClashesWithContextReceivers.diag.txt +++ b/compiler/testData/diagnostics/testsWithStdLib/labelClashesWithContextReceivers.diag.txt @@ -1,12 +1,6 @@ -/labelClashesWithContextReceivers.kt:8:9: warning: the expression is unused - this@Some - ^ /labelClashesWithContextReceivers.kt:8:13: warning: this label is now resolved to 'class Some' but soon it will be resolved to the closest 'function foo context receiver'. Please consider introducing or changing explicit label name this@Some ^ -/labelClashesWithContextReceivers.kt:9:9: warning: the expression is unused - this@String - ^ /labelClashesWithContextReceivers.kt:14:21: warning: this label is now resolved to 'class Some' but soon it will be resolved to the closest 'property self context receiver'. Please consider introducing or changing explicit label name get() = this@Some ^ diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/DiagnosticMessagesTextHandler.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/DiagnosticMessagesTextHandler.kt index f7624a0b05d..c5df2ecda1b 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/DiagnosticMessagesTextHandler.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/frontend/classic/handlers/DiagnosticMessagesTextHandler.kt @@ -9,11 +9,14 @@ import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport import org.jetbrains.kotlin.cli.common.messages.GroupingMessageCollector import org.jetbrains.kotlin.cli.common.messages.MessageRenderer import org.jetbrains.kotlin.cli.common.messages.PrintingMessageCollector +import org.jetbrains.kotlin.diagnostics.GenericDiagnostics +import org.jetbrains.kotlin.diagnostics.UnboundDiagnostic import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives import org.jetbrains.kotlin.test.directives.model.DirectivesContainer import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendOutputArtifact import org.jetbrains.kotlin.test.model.TestModule import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.diagnosticsService import org.jetbrains.kotlin.test.services.moduleStructure import org.jetbrains.kotlin.test.utils.MultiModuleInfoDumper import org.jetbrains.kotlin.test.utils.withExtension @@ -50,7 +53,11 @@ class DiagnosticMessagesTextHandler( ) AnalyzerWithCompilerReport.reportDiagnostics( - info.analysisResult.bindingContext.diagnostics, + object : GenericDiagnostics { + override fun all() = info.analysisResult.bindingContext.diagnostics.filter { + testServices.diagnosticsService.shouldRenderDiagnostic(module, it.factoryName, it.severity) + } + }, diagnosticsFullTextCollector, renderInternalDiagnosticName = false )