From a2c12aa71101fc0257595317c53b63807140dbde Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 15 Sep 2022 14:23:45 +0300 Subject: [PATCH] [FE] Always report UNINITIALIZED_ENUM_COMPANION_WARNING ^KT-54055 --- .../EnumCompanionInEnumConstructorCallChecker.kt | 16 ---------------- .../uninitializedCompanionOfEnum_before.kt | 8 ++++---- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/EnumCompanionInEnumConstructorCallChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/EnumCompanionInEnumConstructorCallChecker.kt index e4433984648..54e766f5826 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/EnumCompanionInEnumConstructorCallChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/EnumCompanionInEnumConstructorCallChecker.kt @@ -67,22 +67,6 @@ object EnumCompanionInEnumConstructorCallChecker : DeclarationChecker { val dispatchIsCompanion = dispatchDescriptor == companionDescriptor val extensionIsCompanion = extensionDescriptor == companionDescriptor - val dispatchIsImplicit = resolvedCall.dispatchReceiver is ImplicitClassReceiver - val extensionIsImplicit = resolvedCall.extensionReceiver is ImplicitClassReceiver - - /* - * ControlFlowInformationProviderImpl already reports UNINITIALIZED_ENUM_COMPANION for extension function calls - * with implicit companion receiver, so we should skip reporting a warning - * - * If feature is enabled then ControlFlowInformationProviderImpl won't report an error, to keep all checks - * in one place (in this checker) - */ - if ( - !reportError && - expression is KtCallExpression && - (dispatchIsCompanion && dispatchIsImplicit || extensionIsCompanion && extensionIsImplicit) - ) return false - if (dispatchIsCompanion || extensionIsCompanion) { val reportOn = when (val receiverExpression = (expression as? KtQualifiedExpression)?.receiverExpression) { is KtSimpleNameExpression -> receiverExpression diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/uninitializedCompanionOfEnum_before.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/uninitializedCompanionOfEnum_before.kt index a738151cad0..4917a7bf4ad 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/uninitializedCompanionOfEnum_before.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/uninitializedCompanionOfEnum_before.kt @@ -2,7 +2,7 @@ // ISSUE: KT-49110, KT-54055 enum class SomeEnum(val x: Int) { - A(companionFun().length),// UNINITIALIZED_ENUM_COMPANION + A(companionFun().length),// UNINITIALIZED_ENUM_COMPANION B(companionProp.length), // UNINITIALIZED_VARIABLE C(SomeEnum.companionFun().length), @@ -18,7 +18,7 @@ enum class SomeEnum(val x: Int) { } enum class OtherEnum(val x: Int) { - G(extensionFun().length), // UNINITIALIZED_ENUM_COMPANION + G(extensionFun().length), // UNINITIALIZED_ENUM_COMPANION H(extensionProp.length), I(OtherEnum.extensionFun().length), @@ -39,13 +39,13 @@ val OtherEnum.Companion.extensionProp: String enum class EnumWithLambda(val lambda: () -> Unit) { M({ - companionFun().length + companionFun().length companionProp.length EnumWithLambda.companionFun().length EnumWithLambda.companionProp.length - extensionFun().length + extensionFun().length extensionProp.length EnumWithLambda.extensionFun().length