From dc4aa8c15e31f723901d4a7a37d5ad3b7012469a Mon Sep 17 00:00:00 2001 From: Svyatoslav Kuzmich Date: Wed, 17 May 2023 09:15:07 +0200 Subject: [PATCH] [Wasm] Restore binary compatibility of PlatformDiagnosticSuppressor Keep the original shouldReportUnusedParameter method without BindingContext parameter ^KT-58188 Fixed --- .../kotlin/cfg/ControlFlowInformationProviderImpl.kt | 3 ++- .../resolve/checkers/PlatformDiagnosticSuppressor.kt | 9 ++++++++- .../org/jetbrains/kotlin/js/analyze/suppressWarnings.kt | 4 +--- .../kotlin/wasm/analyze/WasmDiagnosticSuppressor.kt | 3 +++ .../kotlin/wasm/resolve/WasmPlatformConfigurator.kt | 1 + 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt index 3309e5c2967..1a555d6cd77 100644 --- a/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt +++ b/compiler/frontend/cfg/src/org/jetbrains/kotlin/cfg/ControlFlowInformationProviderImpl.kt @@ -780,7 +780,8 @@ class ControlFlowInformationProviderImpl private constructor( if (functionDescriptor.isExpect || functionDescriptor.isActual || functionDescriptor.isEffectivelyExternal() || - !diagnosticSuppressor.shouldReportUnusedParameter(variableDescriptor, trace.bindingContext) + !diagnosticSuppressor.shouldReportUnusedParameter(variableDescriptor, trace.bindingContext) || + !diagnosticSuppressor.shouldReportUnusedParameter(variableDescriptor) ) return when (val owner = element.parent.parent) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/PlatformDiagnosticSuppressor.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/PlatformDiagnosticSuppressor.kt index a11e02802c1..a18f9a0ca9e 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/PlatformDiagnosticSuppressor.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/PlatformDiagnosticSuppressor.kt @@ -25,11 +25,15 @@ import org.jetbrains.kotlin.resolve.BindingContext @DefaultImplementation(PlatformDiagnosticSuppressor.Default::class) interface PlatformDiagnosticSuppressor : PlatformSpecificExtension{ - fun shouldReportUnusedParameter(parameter: VariableDescriptor, bindingContext: BindingContext): Boolean + // Function without binding context is kept for binary compatibility + // Diagnostic should be suppressed if any of two overloads return false + fun shouldReportUnusedParameter(parameter: VariableDescriptor): Boolean + fun shouldReportUnusedParameter(parameter: VariableDescriptor, bindingContext: BindingContext): Boolean = true fun shouldReportNoBody(descriptor: CallableMemberDescriptor): Boolean object Default : PlatformDiagnosticSuppressor { + override fun shouldReportUnusedParameter(parameter: VariableDescriptor): Boolean = true override fun shouldReportUnusedParameter(parameter: VariableDescriptor, bindingContext: BindingContext): Boolean = true override fun shouldReportNoBody(descriptor: CallableMemberDescriptor): Boolean = true @@ -40,6 +44,9 @@ class CompositePlatformDiagnosticSuppressor(private val suppressors: List