[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.
*/
@@ -25,7 +25,7 @@ object ChangeBoxingMethodTransformer : MethodTransformer() {
init {
val map = hashMapOf<String, String>()
for (primitiveType in JvmPrimitiveType.values()) {
for (primitiveType in JvmPrimitiveType.entries) {
val name = primitiveType.wrapperFqName.topLevelClassInternalName()
map[name] = "box${primitiveType.javaKeywordName.replaceFirstChar(Char::uppercaseChar)}"
}
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
package org.jetbrains.kotlin.codegen.optimization
@@ -236,7 +225,7 @@ internal const val INIT_METHOD_NAME = "<init>"
internal val REF_TYPE_TO_ELEMENT_TYPE = HashMap<String, Type>().apply {
put(AsmTypes.OBJECT_REF_TYPE.internalName, AsmTypes.OBJECT_TYPE)
PrimitiveType.values().forEach {
PrimitiveType.entries.forEach {
put(AsmTypes.sharedTypeForPrimitive(it).internalName, AsmTypes.valueTypeForPrimitive(it))
}
}
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
package org.jetbrains.kotlin.codegen.optimization.boxing
@@ -262,7 +251,7 @@ fun AbstractInsnNode.isPrimitiveBoxing() =
private val BOXING_CLASS_INTERNAL_NAME =
StandardNames.COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("Boxing")).topLevelClassInternalName()
private fun isJvmPrimitiveName(name: String) = JvmPrimitiveType.values().any { it.javaKeywordName == name }
private fun isJvmPrimitiveName(name: String) = JvmPrimitiveType.entries.any { it.javaKeywordName == name }
fun AbstractInsnNode.isCoroutinePrimitiveBoxing(): Boolean {
return isMethodInsnWith(Opcodes.INVOKESTATIC) {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -11,7 +11,7 @@ import com.intellij.pom.java.LanguageLevel
fun Project.setupHighestLanguageLevel() {
LanguageLevelProjectExtension.getInstance(this).languageLevel =
LanguageLevel.values().firstOrNull { it.name == "JDK_17" }
?: LanguageLevel.values().firstOrNull { it.name == "JDK_15_PREVIEW" }
LanguageLevel.entries.firstOrNull { it.name == "JDK_17" }
?: LanguageLevel.entries.firstOrNull { it.name == "JDK_15_PREVIEW" }
?: LanguageLevel.JDK_X
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -1027,7 +1027,7 @@ The corresponding calls' declarations may not be marked with @BuilderInference."
if (value == null) null
else LanguageVersion.fromVersionString(value)
?: run {
val versionStrings = LanguageVersion.values().filterNot(LanguageVersion::isUnsupported).map(LanguageVersion::description)
val versionStrings = LanguageVersion.entries.filterNot(LanguageVersion::isUnsupported).map(LanguageVersion::description)
val message = "Unknown $versionOf version: $value\nSupported $versionOf versions: ${versionStrings.joinToString(", ")}"
collector.report(CompilerMessageSeverity.ERROR, message, null)
null
@@ -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.
*/
@@ -856,7 +856,7 @@ This option is deprecated and will be deleted in future versions."""
result[JvmAnalysisFlags.jvmDefaultMode] = it
} ?: collector.report(
CompilerMessageSeverity.ERROR,
"Unknown -Xjvm-default mode: $jvmDefault, supported modes: ${JvmDefaultMode.values().map(JvmDefaultMode::description)}"
"Unknown -Xjvm-default mode: $jvmDefault, supported modes: ${JvmDefaultMode.entries.map(JvmDefaultMode::description)}"
)
result[JvmAnalysisFlags.inheritMultifileParts] = inheritMultifileParts
result[JvmAnalysisFlags.sanitizeParentheses] = sanitizeParentheses
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
package org.jetbrains.kotlin.runner
@@ -45,7 +34,7 @@ object Main {
val validValues = "${GUESS.argName} (default), ${CLASSFILE.argName}, ${JAR.argName}, ${SCRIPT.argName} (or .<script filename extension>)"
fun fromArg(name: String): HowToRun? =
HowToRun.values().find { it.argName == name }
HowToRun.entries.find { it.argName == name }
}
}
@@ -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.
*/
@@ -79,7 +79,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
} else {
messageCollector.report(
ERROR, "Unknown JVM target version: $jvmTargetValue\n" +
"Supported versions: ${JvmTarget.values().joinToString { it.description }}"
"Supported versions: ${JvmTarget.entries.joinToString { it.description }}"
)
}
}
@@ -100,7 +100,7 @@ fun CompilerConfiguration.setupJvmSpecificArguments(arguments: K2JVMCompilerArgu
} else {
messageCollector.report(
ERROR, "Unknown `-Xstring-concat` mode: $stringConcat\n" +
"Supported modes: ${JvmStringConcat.values().joinToString { it.description }}"
"Supported modes: ${JvmStringConcat.entries.joinToString { it.description }}"
)
}
}
@@ -134,7 +134,7 @@ private fun CompilerConfiguration.handleClosureGenerationSchemeArgument(
messageCollector.report(
ERROR,
"Unknown `$flag` argument: ${value}\n." +
"Supported arguments: ${JvmClosureGenerationScheme.values().joinToString { it.description }}"
"Supported arguments: ${JvmClosureGenerationScheme.entries.joinToString { it.description }}"
)
}
}
@@ -268,7 +268,7 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
if (abiStability == null) {
messageCollector.report(
ERROR,
"Unknown ABI stability mode: ${arguments.abiStability}, supported modes: ${JvmAbiStability.values().map { it.description }}"
"Unknown ABI stability mode: ${arguments.abiStability}, supported modes: ${JvmAbiStability.entries.map { it.description }}"
)
} else if (!useIR && abiStability == JvmAbiStability.UNSTABLE) {
messageCollector.report(ERROR, "-Xabi-stability=unstable is not supported in the old JVM backend")
@@ -306,7 +306,7 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
if (assertionsMode == null) {
messageCollector.report(
ERROR,
"Unknown assertions mode: ${arguments.assertionsMode}, supported modes: ${JVMAssertionsMode.values().map { it.description }}"
"Unknown assertions mode: ${arguments.assertionsMode}, supported modes: ${JVMAssertionsMode.entries.map { it.description }}"
)
}
put(JVMConfigurationKeys.ASSERTIONS_MODE, assertionsMode ?: JVMAssertionsMode.DEFAULT)
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
package org.jetbrains.kotlin.compilerRunner
@@ -31,7 +20,7 @@ import java.util.concurrent.TimeUnit
object KotlinCompilerRunnerUtils {
fun exitCodeFromProcessExitCode(log: KotlinLogger, code: Int): ExitCode {
val exitCode = ExitCode.values().find { it.code == code }
val exitCode = ExitCode.entries.find { it.code == code }
if (exitCode != null) return exitCode
log.debug("Could not find exit code by value: $code")
@@ -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.
*/
@@ -16,7 +16,7 @@ enum class JVMAssertionsMode(val description: String) {
val DEFAULT = LEGACY
@JvmStatic
fun fromStringOrNull(string: String?) = values().find { it.description == string }
fun fromStringOrNull(string: String?) = entries.find { it.description == string }
@JvmStatic
fun fromString(string: String?) = fromStringOrNull(string) ?: DEFAULT
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -11,7 +11,6 @@ enum class JvmAbiStability(val description: String) {
;
companion object {
fun fromStringOrNull(string: String?): JvmAbiStability? =
values().find { it.description == string }
fun fromStringOrNull(string: String?): JvmAbiStability? = entries.find { it.description == string }
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -16,7 +16,7 @@ enum class JvmClosureGenerationScheme(val description: String) {
@JvmStatic
fun fromString(string: String?): JvmClosureGenerationScheme? {
val lowerStr = string?.toLowerCaseAsciiOnly() ?: return null
return values().find { it.description == lowerStr }
return entries.find { it.description == lowerStr }
}
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -12,7 +12,7 @@ enum class JvmSerializeIrMode(val description: String) {
companion object {
@JvmStatic
fun fromStringOrNull(string: String) = values().find { it.description == string }
fun fromStringOrNull(string: String) = entries.find { it.description == string }
@JvmStatic
fun fromString(string: String) = fromStringOrNull(string) ?: NONE
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -15,6 +15,6 @@ enum class JvmStringConcat(val description: String) {
companion object {
@JvmStatic
fun fromString(string: String) = values().find { it.description == string }
fun fromString(string: String) = entries.find { it.description == string }
}
}
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* 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.
*/
package org.jetbrains.kotlin.platform.jvm
@@ -8,8 +8,8 @@ package org.jetbrains.kotlin.platform.jvm
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.platform.SimplePlatform
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.toTargetPlatform
import org.jetbrains.kotlin.platform.TargetPlatformVersion
import org.jetbrains.kotlin.platform.toTargetPlatform
abstract class JvmPlatform : SimplePlatform("JVM") {
override val oldFashionedDescription: String
@@ -20,7 +20,7 @@ abstract class JvmPlatform : SimplePlatform("JVM") {
object JvmPlatforms {
private val UNSPECIFIED_SIMPLE_JVM_PLATFORM = JdkPlatform(JvmTarget.DEFAULT)
private val jvmTargetToJdkPlatform: Map<JvmTarget, TargetPlatform> =
JvmTarget.values().map { it to JdkPlatform(it).toTargetPlatform() }.toMap()
JvmTarget.entries.map { it to JdkPlatform(it).toTargetPlatform() }.toMap()
// This platform is needed mostly for compatibility and migration of code base,
// as previously some clients used TargetPlatform just as platform-marker
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
package org.jetbrains.kotlin.daemon.common
@@ -36,8 +25,7 @@ enum class ReportCategory(val code: Int) {
OUTPUT_MESSAGE(4);
companion object {
fun fromCode(code: Int): ReportCategory? =
ReportCategory.values().firstOrNull { it.code == code }
fun fromCode(code: Int): ReportCategory? = entries.firstOrNull { it.code == code }
}
}
@@ -49,7 +37,7 @@ enum class ReportSeverity(val code: Int) {
companion object {
fun fromCode(code: Int): ReportSeverity {
return values().firstOrNull { it.code == code } ?: error("Can't find a matching ReportSeverity with code = $code")
return entries.firstOrNull { it.code == code } ?: error("Can't find a matching ReportSeverity with code = $code")
}
}
}
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
package org.jetbrains.kotlin.daemon
@@ -232,7 +221,7 @@ abstract class CompileServiceImplBase(
protected fun Int.toAlivenessName(): String =
try {
Aliveness.values()[this].name
Aliveness.entries[this].name
} catch (_: Throwable) {
"invalid($this)"
}
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
package org.jetbrains.kotlin.daemon.report
@@ -47,7 +36,7 @@ fun getBuildReporter(
val requestedResults = compilationOptions
.requestedCompilationResults
.mapNotNullTo(HashSet()) { resultCode ->
CompilationResultCategory.values().getOrNull(resultCode)
CompilationResultCategory.entries.getOrNull(resultCode)
}
for (requestedResult in requestedResults) {
when (requestedResult) {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 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.
*/
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.fir.declarations.*
import org.jetbrains.kotlin.fir.declarations.utils.*
import org.jetbrains.kotlin.fir.declarations.utils.isActual
import org.jetbrains.kotlin.fir.declarations.utils.isExpect
import org.jetbrains.kotlin.fir.declarations.utils.isExternal
import org.jetbrains.kotlin.fir.isSubstitutionOrIntersectionOverride
import org.jetbrains.kotlin.fir.resolve.providers.firProvider
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
@@ -101,7 +100,7 @@ fun FirBasedSymbol<*>.isPredefinedObject(session: FirSession): Boolean {
if (fir is FirMemberDeclaration && isExpect) return true
if (isEffectivelyExternalMember(session)) return true
for (annotation in PredefinedAnnotation.values()) {
for (annotation in PredefinedAnnotation.entries) {
if (hasAnnotationOrInsideAnnotatedClass(annotation.classId, session)) {
return true
}
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* 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.
*/
package org.jetbrains.kotlin.fir.lightTree.fir.modifier
@@ -125,7 +125,7 @@ open class Modifier(var modifiers: Long = ModifierFlag.NONE.value) {
override fun toString(): String {
val result = StringBuilder()
var firstAppend = true
for (value in ModifierFlag.Values) {
for (value in ModifierFlag.entries) {
if (hasFlag(value) && value != ModifierFlag.NONE) {
if (firstAppend) {
firstAppend = false
@@ -1,5 +1,5 @@
/*
* Copyright 201L0-201L9 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.
*/
@@ -49,7 +49,6 @@ enum class ModifierFlag(val value: Long) {
REIFICATION_REIFIED(1L shl 36);
companion object {
val Values = values()
val ElementTypeToModifierFlagMap: Map<IElementType, ModifierFlag> = mutableMapOf(
// Class
KtTokens.ENUM_KEYWORD to CLASS_ENUM,
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 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.
*/
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 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.
*/
@@ -63,9 +63,10 @@ private inline fun <T : FirResolveProcessor> createAllResolveProcessors(
): List<T> {
@Suppress("NAME_SHADOWING")
val scopeSession = scopeSession ?: ScopeSession()
val phases = FirResolvePhase.values().filter {
val phases = FirResolvePhase.entries.filter {
!it.noProcessor
}
return phases.map { it.creator(scopeSession) }
}
@@ -183,8 +183,8 @@ enum class FirResolvePhase(val noProcessor: Boolean = false) {
*/
BODY_RESOLVE;
val next: FirResolvePhase get() = values()[ordinal + 1]
val previous: FirResolvePhase get() = values()[ordinal - 1]
val next: FirResolvePhase get() = entries[ordinal + 1]
val previous: FirResolvePhase get() = entries[ordinal - 1]
companion object {
// Short-cut
@@ -39,7 +39,7 @@ class FirResolvedToPhaseState private constructor(
override val resolvePhase: FirResolvePhase
) : FirResolveState() {
companion object {
private val phases: List<FirResolvedToPhaseState> = FirResolvePhase.values().map(::FirResolvedToPhaseState)
private val phases: List<FirResolvedToPhaseState> = FirResolvePhase.entries.map(::FirResolvedToPhaseState)
operator fun invoke(phase: FirResolvePhase) = phases[phase.ordinal]
}
@@ -76,7 +76,7 @@ class FirInProcessOfResolvingToPhaseStateWithoutBarrier private constructor(
override val resolvingTo: FirResolvePhase
) : FirInProcessOfResolvingToPhaseState() {
companion object {
private val phases: List<FirInProcessOfResolvingToPhaseState> = FirResolvePhase.values()
private val phases: List<FirInProcessOfResolvingToPhaseState> = FirResolvePhase.entries
.drop(1) // drop FirResolvePhase.RAW_FIR phase
.map(::FirInProcessOfResolvingToPhaseStateWithoutBarrier)
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 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.
*/
@@ -28,7 +28,7 @@ private val LANGUAGE_TO_METADATA_VERSION = EnumMap<LanguageVersion, JvmMetadataV
this[LanguageVersion.KOTLIN_2_0] = JvmMetadataVersion.INSTANCE
this[LanguageVersion.KOTLIN_2_1] = JvmMetadataVersion(2, 1, 0)
check(size == LanguageVersion.values().size) {
check(size == LanguageVersion.entries.size) {
"Please add mappings from the missing LanguageVersion instances to the corresponding JvmMetadataVersion " +
"in `LANGUAGE_TO_METADATA_VERSION`"
}
@@ -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,
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 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.
*/
@@ -46,7 +46,7 @@ open class BuiltinSymbolsBase(val irBuiltIns: IrBuiltIns, private val symbolTabl
val charSequence = getClass(Name.identifier("CharSequence"), "kotlin")
val string = getClass(Name.identifier("String"), "kotlin")
val primitiveIteratorsByType = PrimitiveType.values().associate { type ->
val primitiveIteratorsByType = PrimitiveType.entries.associate { type ->
val iteratorClass = getClass(Name.identifier(type.typeName.asString() + "Iterator"), "kotlin", "collections")
type to iteratorClass
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 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.
*/
@@ -281,7 +281,7 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
val jsArrayIteratorFunction = getInternalFunction("arrayIterator")
val jsPrimitiveArrayIteratorFunctions =
PrimitiveType.values().associate { it to getInternalFunction("${it.typeName.asString().toLowerCaseAsciiOnly()}ArrayIterator") }
PrimitiveType.entries.associate { it to getInternalFunction("${it.typeName.asString().toLowerCaseAsciiOnly()}ArrayIterator") }
val jsClass = getInternalFunction("jsClassIntrinsic")
val arrayLiteral: IrSimpleFunctionSymbol = getInternalFunction("arrayLiteral")
@@ -321,14 +321,14 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
)
val primitiveToSizeConstructor =
PrimitiveType.values().associate { type ->
PrimitiveType.entries.associate { type ->
type to (primitiveToTypedArrayMap[type]?.let {
getInternalFunction("${it.toLowerCaseAsciiOnly()}Array")
} ?: getInternalFunction("${type.typeName.asString().toLowerCaseAsciiOnly()}Array"))
}
val primitiveToLiteralConstructor =
PrimitiveType.values().associate { type ->
PrimitiveType.entries.associate { type ->
type to (primitiveToTypedArrayMap[type]?.let {
getInternalFunction("${it.toLowerCaseAsciiOnly()}ArrayOf")
} ?: getInternalFunction("${type.typeName.asString().toLowerCaseAsciiOnly()}ArrayOf"))
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -276,10 +276,10 @@ private class JsIrAstDeserializer(private val source: ByteArray) {
}
}
private val sideEffectKindValues = SideEffectKind.values()
private val jsBinaryOperatorValues = JsBinaryOperator.values()
private val jsUnaryOperatorValues = JsUnaryOperator.values()
private val jsFunctionModifiersValues = JsFunction.Modifier.values()
private val sideEffectKindValues get() = SideEffectKind.entries
private val jsBinaryOperatorValues get() = JsBinaryOperator.entries
private val jsUnaryOperatorValues get() = JsUnaryOperator.entries
private val jsFunctionModifiersValues get() = JsFunction.Modifier.entries
private fun readExpression(): JsExpression {
return withComments {
@@ -450,7 +450,7 @@ private class JsIrAstDeserializer(private val source: ByteArray) {
}
}
private val specialFunctionValues = SpecialFunction.values()
private val specialFunctionValues get() = SpecialFunction.entries
private fun readName(): JsName {
val identifier = stringTable[readInt()]
@@ -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.
*/
@@ -94,7 +94,7 @@ internal class VarargLowering(val context: JvmBackendContext) : FileLoweringPass
}
internal val PRIMITIVE_ARRAY_OF_NAMES: Set<String> =
(PrimitiveType.values().map { type -> type.name } + UnsignedType.values().map { type -> type.typeName.asString() })
(PrimitiveType.entries.map { type -> type.name } + UnsignedType.entries.map { type -> type.typeName.asString() })
.map { name -> name.toLowerCaseAsciiOnly() + "ArrayOf" }.toSet()
internal const val ARRAY_OF_NAME = "arrayOf"
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 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.
*/
@@ -444,13 +444,13 @@ class IrBuiltInsOverDescriptors(
override val booleanArray = builtIns.getPrimitiveArrayClassDescriptor(PrimitiveType.BOOLEAN).toIrSymbol()
override val primitiveArraysToPrimitiveTypes =
PrimitiveType.values().associate { builtIns.getPrimitiveArrayClassDescriptor(it).toIrSymbol() to it }
PrimitiveType.entries.associate { builtIns.getPrimitiveArrayClassDescriptor(it).toIrSymbol() to it }
override val primitiveTypesToPrimitiveArrays = primitiveArraysToPrimitiveTypes.map { (k, v) -> v to k }.toMap()
override val primitiveArrayElementTypes = primitiveArraysToPrimitiveTypes.mapValues { primitiveTypeToIrType[it.value] }
override val primitiveArrayForType = primitiveArrayElementTypes.asSequence().associate { it.value to it.key }
override val unsignedTypesToUnsignedArrays: Map<UnsignedType, IrClassSymbol> =
UnsignedType.values().mapNotNull { unsignedType ->
UnsignedType.entries.mapNotNull { unsignedType ->
val array = builtIns.builtInsModule.findClassAcrossModuleDependencies(unsignedType.arrayClassId)?.toIrSymbol()
if (array == null) null else unsignedType to array
}.toMap()
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 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.
*/
@@ -26,7 +26,7 @@ enum class PartialLinkageMode(val isEnabled: Boolean) {
val DEFAULT = ENABLE
fun resolveMode(key: String): PartialLinkageMode? =
values().firstOrNull { entry -> entry.name.equals(key, ignoreCase = true) }
entries.firstOrNull { entry -> entry.name.equals(key, ignoreCase = true) }
}
}
@@ -37,7 +37,7 @@ enum class PartialLinkageLogLevel {
val DEFAULT = INFO
fun resolveLogLevel(key: String): PartialLinkageLogLevel? =
values().firstOrNull { entry -> entry.name.equals(key, ignoreCase = true) }
entries.firstOrNull { entry -> entry.name.equals(key, ignoreCase = true) }
}
}
@@ -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.
*/
@@ -89,23 +89,23 @@ private fun classFqNameEquals(symbol: IrClassSymbol, fqName: FqNameUnsafe): Bool
}
private val idSignatureToPrimitiveType: Map<IdSignature.CommonSignature, PrimitiveType> =
PrimitiveType.values().associateBy {
PrimitiveType.entries.associateBy {
getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, it.typeName.asString())
}
private val shortNameToPrimitiveType: Map<Name, PrimitiveType> =
PrimitiveType.values().associateBy(PrimitiveType::typeName)
PrimitiveType.entries.associateBy(PrimitiveType::typeName)
private val idSignatureToUnsignedType: Map<IdSignature.CommonSignature, UnsignedType> =
UnsignedType.values().associateBy {
UnsignedType.entries.associateBy {
getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, it.typeName.asString())
}
private val shortNameToUnsignedType: Map<Name, UnsignedType> =
UnsignedType.values().associateBy(UnsignedType::typeName)
UnsignedType.entries.associateBy(UnsignedType::typeName)
val primitiveArrayTypesSignatures: Map<PrimitiveType, IdSignature.CommonSignature> =
PrimitiveType.values().associateWith {
PrimitiveType.entries.associateWith {
getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, "${it.typeName.asString()}Array")
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -305,7 +305,7 @@ sealed class IdSignature {
val nameSegments: List<String> get() = declarationFqName.split('.')
private fun adaptMask(old: Long): Long =
old xor Flags.values().fold(0L) { a, f ->
old xor Flags.entries.fold(0L) { a, f ->
if (!f.recursive) a or (old and (1L shl f.ordinal))
else a
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 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.
*/
@@ -48,12 +48,12 @@ internal class ClassifierExplorer(
buildSet {
this += permittedAnnotationArrayParameterSymbols
PrimitiveType.values().forEach {
PrimitiveType.entries.forEach {
addIfNotNull(builtIns.findClass(it.typeName, BUILT_INS_PACKAGE_FQ_NAME)) // kotlin.<primitive>
addIfNotNull(builtIns.findClass(it.arrayTypeName, BUILT_INS_PACKAGE_FQ_NAME)) // kotlin.<primitive>Array
}
UnsignedType.values().forEach {
UnsignedType.entries.forEach {
addIfNotNull(builtIns.findClass(it.typeName, BUILT_INS_PACKAGE_FQ_NAME)) // kotlin.U<signed>
addIfNotNull(builtIns.findClass(it.arrayClassId.shortClassName, BUILT_INS_PACKAGE_FQ_NAME)) // kotlin.U<signed>Array
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -30,7 +30,7 @@ value class BinarySymbolData(val code: Long) {
val signatureId: Int get() = (code ushr 8).toInt()
val kind: SymbolKind
get() = SymbolKind.values()[symbolKindId()]
get() = SymbolKind.entries[symbolKindId()]
companion object {
fun encode(kind: SymbolKind, signatureId: Int): Long {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -17,7 +17,7 @@ value class BinaryTypeProjection(val code: Long) {
val variance: Variance
get() {
assert(!isStarProjection)
return Variance.values()[varianceId()]
return Variance.entries[varianceId()]
}
val typeIndex: Int get() = (code ushr 2).toInt()
@@ -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.
*/
@@ -53,7 +53,7 @@ class KtConstantExpressionElementType(@NonNls debugName: String) :
val kindOrdinal = dataStream.readInt()
val value = dataStream.readName() ?: StringRef.fromString("")
val valueKind = ConstantValueKind.values()[kindOrdinal]
val valueKind = ConstantValueKind.entries[kindOrdinal]
return KotlinConstantExpressionStubImpl(
parentStub,
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2023 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.
*/
@@ -14,8 +14,6 @@ import org.jetbrains.kotlin.metadata.deserialization.NameResolver
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.stubs.StubUtils
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
enum class KotlinConstantValueKind {
NULL, BOOLEAN, CHAR, BYTE, SHORT, INT, LONG, DOUBLE, FLOAT, ENUM, KCLASS, STRING, ARRAY, UBYTE, USHORT, UINT, ULONG, ANNO;
@@ -24,7 +22,7 @@ enum class KotlinConstantValueKind {
fun createConstantValue(dataStream: StubInputStream): ConstantValue<*>? {
val kind = dataStream.readInt()
if (kind == -1) return null
return when (KotlinConstantValueKind.values()[kind]) {
return when (KotlinConstantValueKind.entries[kind]) {
KotlinConstantValueKind.NULL -> NullValue
KotlinConstantValueKind.BOOLEAN -> BooleanValue(dataStream.readBoolean())
KotlinConstantValueKind.CHAR -> CharValue(dataStream.readChar())
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -25,7 +25,7 @@ enum class KotlinContractEffectType {
CALLS {
override fun deserialize(dataStream: StubInputStream): KtCallsEffectDeclaration<KotlinTypeBean, Nothing?> {
val declaration = PARAMETER_REFERENCE.deserialize(dataStream)
val range = EventOccurrencesRange.values()[dataStream.readInt()]
val range = EventOccurrencesRange.entries[dataStream.readInt()]
return KtCallsEffectDeclaration(declaration as KtValueParameterReference, range)
}
},
@@ -36,8 +36,8 @@ enum class KotlinContractEffectType {
},
CONDITIONAL {
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
val descriptionElement = values()[dataStream.readInt()].deserialize(dataStream)
val condition = values()[dataStream.readInt()].deserialize(dataStream)
val descriptionElement = entries[dataStream.readInt()].deserialize(dataStream)
val condition = entries[dataStream.readInt()].deserialize(dataStream)
return KtConditionalEffectDeclaration(
descriptionElement as KtEffectDeclaration,
condition as KtBooleanExpression
@@ -63,14 +63,14 @@ enum class KotlinContractEffectType {
},
NOT {
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
return KtLogicalNot(values()[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression)
return KtLogicalNot(entries[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression)
}
},
BOOLEAN_LOGIC {
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
val kind = if (dataStream.readBoolean()) LogicOperationKind.AND else LogicOperationKind.OR
val left = values()[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
val right = values()[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
val left = entries[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
val right = entries[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
return KtBinaryLogicExpression(left, right, kind)
}
},
@@ -1,17 +1,6 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* 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.
*/
package org.jetbrains.kotlin.psi.stubs.impl
@@ -70,7 +59,7 @@ class KotlinFunctionStubImpl(
val effects = mutableListOf<KtContractDescriptionElement<KotlinTypeBean, Nothing?>>()
val count: Int = dataStream.readInt()
for (i in 0 until count) {
val effectType: KotlinContractEffectType = KotlinContractEffectType.values()[dataStream.readInt()]
val effectType: KotlinContractEffectType = KotlinContractEffectType.entries[dataStream.readInt()]
effects.add(effectType.deserialize(dataStream))
}
return effects
@@ -1,13 +1,13 @@
/*
* Copyright 2010-2020 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.
*/
package org.jetbrains.kotlin.test.services.impl
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.JsPlatform
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.js.JsPlatforms
import org.jetbrains.kotlin.platform.jvm.JdkPlatform
import org.jetbrains.kotlin.platform.konan.NativePlatform
@@ -34,8 +34,8 @@ object TargetPlatformParser {
val target = when {
platformString == JVM -> JvmTarget.DEFAULT
!platformString.startsWith(JDK) -> return null
else -> JvmTarget.values().find { it.name == platformString }
?: error("JvmTarget \"$platformString\" not found.\nAvailable targets: ${JvmTarget.values().joinToArrayString()}")
else -> JvmTarget.entries.find { it.name == platformString }
?: error("JvmTarget \"$platformString\" not found.\nAvailable targets: ${JvmTarget.entries.joinToArrayString()}")
}
return JdkPlatform(target)
}
@@ -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.
*/
@@ -61,7 +61,7 @@ class TestExceptionsComparator(wholeFile: File) {
}
private fun validateExistingExceptionFiles(e: TestsError?) {
val postfixesOfFilesToCheck = TestsExceptionType.values().toMutableSet().filter { it != e?.type }
val postfixesOfFilesToCheck = TestsExceptionType.entries.toMutableSet().filter { it != e?.type }
postfixesOfFilesToCheck.forEach {
if (File("$filePathPrefix.${it.postfix}.txt").exists())
@@ -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.
*/
@@ -136,7 +136,7 @@ private fun collectLanguageFeatureMap(directives: String): Map<LanguageFeature,
val name = matcher.group(2)
val feature = LanguageFeature.fromString(name) ?: throw AssertionError(
"Language feature not found, please check spelling: $name\n" +
"Known features:\n ${LanguageFeature.values().joinToString("\n ")}"
"Known features:\n ${LanguageFeature.entries.joinToString("\n ")}"
)
if (values.put(feature, mode) != null) {
Assert.fail("Duplicate entry for the language feature: $name")
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -15,7 +15,7 @@ enum class TestsExceptionType(val postfix: String) {
INFRASTRUCTURE_ERROR("infrastructure");
companion object {
private val map = values().associateBy(TestsExceptionType::postfix)
private val map = entries.associateBy(TestsExceptionType::postfix)
fun fromValue(type: String) = map[type]
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -277,7 +277,7 @@ class ModuleInfoParser(infoFile: File) : InfoParser<ModuleInfo>(infoFile) {
fun getOpArgs() = line.substring(opIndex + 1).splitAndTrim()
val expectedState = DirtyFileState.values().find { it.str == op }
val expectedState = DirtyFileState.entries.find { it.str == op }
if (expectedState != null) {
expectedFileStats[expectedState.str] = getOpArgs().toSet()
} else {
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* 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.
*/
package org.jetbrains.kotlin.spec.consistency
@@ -26,7 +26,7 @@ class SpecTestsConsistencyTest : TestCase() {
fun getTestFiles(): Stream<String> {
val testFiles = mutableListOf<String>()
TestArea.values().forEach { testArea ->
TestArea.entries.forEach { testArea ->
val testDataPath =
"${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testArea.testDataPath}/${SpecTestLinkedType.LINKED.testDataPath}"
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* 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.
*/
package org.jetbrains.kotlin.spec.utils
@@ -10,9 +10,9 @@ import org.jetbrains.kotlin.spec.utils.GeneralConfiguration.LINKED_TESTS_PATH
import org.jetbrains.kotlin.spec.utils.models.LinkedSpecTestFileInfoElementType
import org.jetbrains.kotlin.spec.utils.models.NotLinkedSpecTestFileInfoElementType
import org.jetbrains.kotlin.spec.utils.parsers.BasePatterns
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.withSpaces
import org.jetbrains.kotlin.spec.utils.parsers.LinkedSpecTestPatterns
import org.jetbrains.kotlin.spec.utils.parsers.NotLinkedSpecTestPatterns
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.withSpaces
import java.util.*
import java.util.regex.Matcher
import java.util.regex.Pattern
@@ -27,8 +27,8 @@ enum class TestType(val type: String) {
NEGATIVE("neg");
companion object {
private val map = values().associateBy(TestType::type)
val joinedValues = values().joinToString("|").withSpaces()
private val map = entries.associateBy(TestType::type)
val joinedValues = entries.joinToString("|").withSpaces()
fun fromValue(type: String) = map[type]
}
@@ -51,7 +51,7 @@ enum class TestArea(val testDataPath: String) {
CODEGEN_BOX("codegen/box");
companion object {
val joinedValues = values().joinToString("|").withSpaces()
val joinedValues = entries.joinToString("|").withSpaces()
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2020 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.
*/
@@ -56,7 +56,7 @@ object SectionsJsonMapGenerator {
) {
companion object {
private fun identifyTestArea(path: String): TestArea {
TestArea.values().forEach {
TestArea.entries.forEach {
if (path.startsWith(it.testDataPath)) return it
}
throw IllegalArgumentException("testsMap path doesn't contain test area path")
@@ -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.
*/
@@ -66,7 +66,7 @@ object TestsJsonMapGenerator {
testOrigin: TestOrigin,
) {
val isImplementationTest = testOrigin == TestOrigin.IMPLEMENTATION
TestArea.values().forEach { testArea ->
TestArea.entries.forEach { testArea ->
File(testOrigin.getFilePath(testArea)).walkTopDown()
.forEach testFiles@{ file ->
if (!file.isFile || file.extension != "kt" || file.isCustomTestData) return@testFiles
@@ -1,6 +1,6 @@
/*
* Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
* 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.
*/
package org.jetbrains.kotlin.spec.utils
@@ -42,7 +42,7 @@ object TestsStatisticCollector {
fun collect(testLinkedType: SpecTestLinkedType): Map<TestArea, SpecTestsStatElement> {
val statistic = mutableMapOf<TestArea, SpecTestsStatElement>()
for (specTestArea in TestArea.values()) {
for (specTestArea in TestArea.entries) {
val specTestsPath = "$SPEC_TESTDATA_PATH/${specTestArea.name.lowercase().replace("_", "/")}/${testLinkedType.testDataPath}"
statistic[specTestArea] =
@@ -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.
*/
@@ -147,7 +147,7 @@ object GenerateInRangeExpressionTestData {
val unsignedNumbers = numbers.drop(1).map { it + "u" }
val allFunctions = Function.values().toList()
val allFunctions = Function.entries
val rangeFunctions = allFunctions - DOWN_TO
generateRangeOperatorTestCases("char", allFunctions, "'1'" to "'3'", charLiterals)
@@ -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.
*/
@@ -150,7 +150,7 @@ object GenerateSteppedRangesCodegenTestData {
function: Function,
extraCode: String? = null,
subdir: String? = null
) = generateTestsForFunction(fileName, Type.values().associate { it to builder }, function, extraCode, subdir)
) = generateTestsForFunction(fileName, Type.entries.associate { it to builder }, function, extraCode, subdir)
private fun generateTestsForFunction(
fileName: String,
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -70,7 +70,7 @@ class ApiVersion private constructor(
val KOTLIN_2_1 = createByLanguageVersion(LanguageVersion.KOTLIN_2_1)
@JvmField
val LATEST: ApiVersion = createByLanguageVersion(LanguageVersion.values().last())
val LATEST: ApiVersion = createByLanguageVersion(LanguageVersion.entries.last())
@JvmField
val LATEST_STABLE: ApiVersion = createByLanguageVersion(LanguageVersion.LATEST_STABLE)
@@ -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.
*/
@@ -11,8 +11,8 @@ enum class ExplicitApiMode(val state: String) {
WARNING("warning");
companion object {
fun fromString(string: String): ExplicitApiMode? = values().find { it.state == string }
fun fromString(string: String): ExplicitApiMode? = entries.find { it.state == string }
fun availableValues() = values().joinToString(prefix = "{", postfix = "}") { it.state }
fun availableValues() = entries.joinToString(prefix = "{", postfix = "}") { it.state }
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2021 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.
*/
@@ -469,7 +469,7 @@ enum class LanguageFeature(
companion object {
@JvmStatic
fun fromString(str: String) = values().find { it.name == str }
fun fromString(str: String) = entries.find { it.name == str }
}
}
@@ -507,7 +507,7 @@ enum class LanguageVersion(val major: Int, val minor: Int) : DescriptionAware, L
companion object {
@JvmStatic
fun fromVersionString(str: String?) = values().find { it.versionString == str }
fun fromVersionString(str: String?) = entries.find { it.versionString == str }
@JvmStatic
fun fromFullVersionString(str: String) =
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 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.
*/
@@ -40,10 +40,10 @@ object AnalysisApiConfiguratorFactoryProvider {
}
val allPossibleFactoryDataList: List<AnalysisApiTestConfiguratorFactoryData> = buildList {
FrontendKind.values().forEach { frontend ->
TestModuleKind.values().forEach { moduleKind ->
AnalysisSessionMode.values().forEach { analysisSessionMode ->
AnalysisApiMode.values().forEach { analysisApiMode ->
FrontendKind.entries.forEach { frontend ->
TestModuleKind.entries.forEach { moduleKind ->
AnalysisSessionMode.entries.forEach { analysisSessionMode ->
AnalysisApiMode.entries.forEach { analysisApiMode ->
add(AnalysisApiTestConfiguratorFactoryData(frontend, moduleKind, analysisSessionMode, analysisApiMode))
}
}