[compiler] replace Enum values() with entries

To fix warnings. Also, use of `Enum.entries` may improve the performance

^KT-48872
This commit is contained in:
Dmitrii Gridin
2024-02-15 00:02:32 +01:00
committed by Space Team
parent ec167d4d42
commit 072d191306
60 changed files with 174 additions and 267 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -123,7 +123,7 @@ class TextDiagnostic(
}
private fun computeInferenceCompatibility(abbreviation: String?): InferenceCompatibility {
return if (abbreviation == null) InferenceCompatibility.ALL else InferenceCompatibility.values().single { inference -> abbreviation == inference.abbreviation }
return if (abbreviation == null) InferenceCompatibility.ALL else InferenceCompatibility.entries.single { inference -> abbreviation == inference.abbreviation }
}
private fun extractDataBefore(prefix: String?, anchor: String): String? {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -861,7 +861,7 @@ class DiagnosticReporterByTrackingStrategy(
if (argumentsExpression != null) {
val specialFunctionName = requireNotNull(
ControlStructureTypingUtils.ResolveConstruct.values().find { specialFunction ->
ControlStructureTypingUtils.ResolveConstruct.entries.find { specialFunction ->
specialFunction.specialFunctionName == resolvedAtom.candidateDescriptor.name
}
) { "Unsupported special construct: ${resolvedAtom.candidateDescriptor.name} not found in special construct names" }
@@ -918,7 +918,7 @@ class DiagnosticReporterByTrackingStrategy(
}
if (atom !is ResolvedCallAtom) return false
return ControlStructureTypingUtils.ResolveConstruct.values().any { specialFunction ->
return ControlStructureTypingUtils.ResolveConstruct.entries.any { specialFunction ->
specialFunction.specialFunctionName == atom.candidateDescriptor.name
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -19,11 +19,6 @@ import org.jetbrains.kotlin.psi.psiUtil.getBinaryWithTypeParent
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil
import org.jetbrains.kotlin.resolve.TemporaryBindingTrace
import org.jetbrains.kotlin.resolve.calls.util.*
import org.jetbrains.kotlin.resolve.calls.util.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS
import org.jetbrains.kotlin.resolve.calls.util.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS
import org.jetbrains.kotlin.resolve.calls.util.getCall
import org.jetbrains.kotlin.resolve.calls.util.isSafeCall
import org.jetbrains.kotlin.resolve.calls.context.CallCandidateResolutionContext
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
@@ -36,11 +31,16 @@ import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.Constrain
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ConstraintPositionKind.VALUE_PARAMETER_POSITION
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ValidityConstraintForConstituentType
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall
import org.jetbrains.kotlin.resolve.calls.util.makeNullableTypeIfSafeReceiver
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.INCOMPLETE_TYPE_INFERENCE
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.OTHER_ERROR
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.calls.util.*
import org.jetbrains.kotlin.resolve.calls.util.ResolveArgumentsMode.RESOLVE_FUNCTION_ARGUMENTS
import org.jetbrains.kotlin.resolve.calls.util.ResolveArgumentsMode.SHAPE_FUNCTION_ARGUMENTS
import org.jetbrains.kotlin.resolve.calls.util.getCall
import org.jetbrains.kotlin.resolve.calls.util.isSafeCall
import org.jetbrains.kotlin.resolve.calls.util.makeNullableTypeIfSafeReceiver
import org.jetbrains.kotlin.resolve.isFunctionForExpectTypeFromCastFeature
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.types.*
@@ -49,7 +49,7 @@ import org.jetbrains.kotlin.types.expressions.ControlStructureTypingUtils.Resolv
import org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils
import org.jetbrains.kotlin.types.typeUtil.makeNullable
val SPECIAL_FUNCTION_NAMES = ResolveConstruct.values().map { it.specialFunctionName }.toSet()
val SPECIAL_FUNCTION_NAMES = ResolveConstruct.entries.map { it.specialFunctionName }.toSet()
class GenericCandidateResolver(
private val argumentTypeResolver: ArgumentTypeResolver,