[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. * 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 { init {
val map = hashMapOf<String, String>() val map = hashMapOf<String, String>()
for (primitiveType in JvmPrimitiveType.values()) { for (primitiveType in JvmPrimitiveType.entries) {
val name = primitiveType.wrapperFqName.topLevelClassInternalName() val name = primitiveType.wrapperFqName.topLevelClassInternalName()
map[name] = "box${primitiveType.javaKeywordName.replaceFirstChar(Char::uppercaseChar)}" map[name] = "box${primitiveType.javaKeywordName.replaceFirstChar(Char::uppercaseChar)}"
} }
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2017 JetBrains s.r.o. * 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.
* 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.
*/ */
package org.jetbrains.kotlin.codegen.optimization 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 { internal val REF_TYPE_TO_ELEMENT_TYPE = HashMap<String, Type>().apply {
put(AsmTypes.OBJECT_REF_TYPE.internalName, AsmTypes.OBJECT_TYPE) put(AsmTypes.OBJECT_REF_TYPE.internalName, AsmTypes.OBJECT_TYPE)
PrimitiveType.values().forEach { PrimitiveType.entries.forEach {
put(AsmTypes.sharedTypeForPrimitive(it).internalName, AsmTypes.valueTypeForPrimitive(it)) put(AsmTypes.sharedTypeForPrimitive(it).internalName, AsmTypes.valueTypeForPrimitive(it))
} }
} }
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * 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.
* 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.
*/ */
package org.jetbrains.kotlin.codegen.optimization.boxing package org.jetbrains.kotlin.codegen.optimization.boxing
@@ -262,7 +251,7 @@ fun AbstractInsnNode.isPrimitiveBoxing() =
private val BOXING_CLASS_INTERNAL_NAME = private val BOXING_CLASS_INTERNAL_NAME =
StandardNames.COROUTINES_JVM_INTERNAL_PACKAGE_FQ_NAME.child(Name.identifier("Boxing")).topLevelClassInternalName() 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 { fun AbstractInsnNode.isCoroutinePrimitiveBoxing(): Boolean {
return isMethodInsnWith(Opcodes.INVOKESTATIC) { 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. * 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() { fun Project.setupHighestLanguageLevel() {
LanguageLevelProjectExtension.getInstance(this).languageLevel = LanguageLevelProjectExtension.getInstance(this).languageLevel =
LanguageLevel.values().firstOrNull { it.name == "JDK_17" } LanguageLevel.entries.firstOrNull { it.name == "JDK_17" }
?: LanguageLevel.values().firstOrNull { it.name == "JDK_15_PREVIEW" } ?: LanguageLevel.entries.firstOrNull { it.name == "JDK_15_PREVIEW" }
?: LanguageLevel.JDK_X ?: 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. * 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 if (value == null) null
else LanguageVersion.fromVersionString(value) else LanguageVersion.fromVersionString(value)
?: run { ?: 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(", ")}" val message = "Unknown $versionOf version: $value\nSupported $versionOf versions: ${versionStrings.joinToString(", ")}"
collector.report(CompilerMessageSeverity.ERROR, message, null) collector.report(CompilerMessageSeverity.ERROR, message, null)
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. * 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 result[JvmAnalysisFlags.jvmDefaultMode] = it
} ?: collector.report( } ?: collector.report(
CompilerMessageSeverity.ERROR, 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.inheritMultifileParts] = inheritMultifileParts
result[JvmAnalysisFlags.sanitizeParentheses] = sanitizeParentheses result[JvmAnalysisFlags.sanitizeParentheses] = sanitizeParentheses
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * 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.
* 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.
*/ */
package org.jetbrains.kotlin.runner 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>)" val validValues = "${GUESS.argName} (default), ${CLASSFILE.argName}, ${JAR.argName}, ${SCRIPT.argName} (or .<script filename extension>)"
fun fromArg(name: String): HowToRun? = 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. * 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 { } else {
messageCollector.report( messageCollector.report(
ERROR, "Unknown JVM target version: $jvmTargetValue\n" + 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 { } else {
messageCollector.report( messageCollector.report(
ERROR, "Unknown `-Xstring-concat` mode: $stringConcat\n" + 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( messageCollector.report(
ERROR, ERROR,
"Unknown `$flag` argument: ${value}\n." + "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) { if (abiStability == null) {
messageCollector.report( messageCollector.report(
ERROR, 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) { } else if (!useIR && abiStability == JvmAbiStability.UNSTABLE) {
messageCollector.report(ERROR, "-Xabi-stability=unstable is not supported in the old JVM backend") 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) { if (assertionsMode == null) {
messageCollector.report( messageCollector.report(
ERROR, 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) put(JVMConfigurationKeys.ASSERTIONS_MODE, assertionsMode ?: JVMAssertionsMode.DEFAULT)
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * 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.
* 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.
*/ */
package org.jetbrains.kotlin.compilerRunner package org.jetbrains.kotlin.compilerRunner
@@ -31,7 +20,7 @@ import java.util.concurrent.TimeUnit
object KotlinCompilerRunnerUtils { object KotlinCompilerRunnerUtils {
fun exitCodeFromProcessExitCode(log: KotlinLogger, code: Int): ExitCode { 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 if (exitCode != null) return exitCode
log.debug("Could not find exit code by value: $code") 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. * 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 val DEFAULT = LEGACY
@JvmStatic @JvmStatic
fun fromStringOrNull(string: String?) = values().find { it.description == string } fun fromStringOrNull(string: String?) = entries.find { it.description == string }
@JvmStatic @JvmStatic
fun fromString(string: String?) = fromStringOrNull(string) ?: DEFAULT 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. * 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 { companion object {
fun fromStringOrNull(string: String?): JvmAbiStability? = fun fromStringOrNull(string: String?): JvmAbiStability? = entries.find { it.description == string }
values().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. * 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 @JvmStatic
fun fromString(string: String?): JvmClosureGenerationScheme? { fun fromString(string: String?): JvmClosureGenerationScheme? {
val lowerStr = string?.toLowerCaseAsciiOnly() ?: return null 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. * 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 { companion object {
@JvmStatic @JvmStatic
fun fromStringOrNull(string: String) = values().find { it.description == string } fun fromStringOrNull(string: String) = entries.find { it.description == string }
@JvmStatic @JvmStatic
fun fromString(string: String) = fromStringOrNull(string) ?: NONE 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. * 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 { companion object {
@JvmStatic @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 * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* that can be found in the license/LICENSE.txt file. * 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 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.config.JvmTarget
import org.jetbrains.kotlin.platform.SimplePlatform import org.jetbrains.kotlin.platform.SimplePlatform
import org.jetbrains.kotlin.platform.TargetPlatform import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.toTargetPlatform
import org.jetbrains.kotlin.platform.TargetPlatformVersion import org.jetbrains.kotlin.platform.TargetPlatformVersion
import org.jetbrains.kotlin.platform.toTargetPlatform
abstract class JvmPlatform : SimplePlatform("JVM") { abstract class JvmPlatform : SimplePlatform("JVM") {
override val oldFashionedDescription: String override val oldFashionedDescription: String
@@ -20,7 +20,7 @@ abstract class JvmPlatform : SimplePlatform("JVM") {
object JvmPlatforms { object JvmPlatforms {
private val UNSPECIFIED_SIMPLE_JVM_PLATFORM = JdkPlatform(JvmTarget.DEFAULT) private val UNSPECIFIED_SIMPLE_JVM_PLATFORM = JdkPlatform(JvmTarget.DEFAULT)
private val jvmTargetToJdkPlatform: Map<JvmTarget, TargetPlatform> = 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, // This platform is needed mostly for compatibility and migration of code base,
// as previously some clients used TargetPlatform just as platform-marker // as previously some clients used TargetPlatform just as platform-marker
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2016 JetBrains s.r.o. * 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.
* 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.
*/ */
package org.jetbrains.kotlin.daemon.common package org.jetbrains.kotlin.daemon.common
@@ -36,8 +25,7 @@ enum class ReportCategory(val code: Int) {
OUTPUT_MESSAGE(4); OUTPUT_MESSAGE(4);
companion object { companion object {
fun fromCode(code: Int): ReportCategory? = fun fromCode(code: Int): ReportCategory? = entries.firstOrNull { it.code == code }
ReportCategory.values().firstOrNull { it.code == code }
} }
} }
@@ -49,7 +37,7 @@ enum class ReportSeverity(val code: Int) {
companion object { companion object {
fun fromCode(code: Int): ReportSeverity { 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. * 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.
* 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.
*/ */
package org.jetbrains.kotlin.daemon package org.jetbrains.kotlin.daemon
@@ -232,7 +221,7 @@ abstract class CompileServiceImplBase(
protected fun Int.toAlivenessName(): String = protected fun Int.toAlivenessName(): String =
try { try {
Aliveness.values()[this].name Aliveness.entries[this].name
} catch (_: Throwable) { } catch (_: Throwable) {
"invalid($this)" "invalid($this)"
} }
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2017 JetBrains s.r.o. * 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.
* 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.
*/ */
package org.jetbrains.kotlin.daemon.report package org.jetbrains.kotlin.daemon.report
@@ -47,7 +36,7 @@ fun getBuildReporter(
val requestedResults = compilationOptions val requestedResults = compilationOptions
.requestedCompilationResults .requestedCompilationResults
.mapNotNullTo(HashSet()) { resultCode -> .mapNotNullTo(HashSet()) { resultCode ->
CompilationResultCategory.values().getOrNull(resultCode) CompilationResultCategory.entries.getOrNull(resultCode)
} }
for (requestedResult in requestedResults) { for (requestedResult in requestedResults) {
when (requestedResult) { 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. * 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.*
import org.jetbrains.kotlin.fir.declarations.utils.isActual import org.jetbrains.kotlin.fir.declarations.utils.isActual
import org.jetbrains.kotlin.fir.declarations.utils.isExpect 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.isSubstitutionOrIntersectionOverride
import org.jetbrains.kotlin.fir.resolve.providers.firProvider import org.jetbrains.kotlin.fir.resolve.providers.firProvider
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol 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 (fir is FirMemberDeclaration && isExpect) return true
if (isEffectivelyExternalMember(session)) return true if (isEffectivelyExternalMember(session)) return true
for (annotation in PredefinedAnnotation.values()) { for (annotation in PredefinedAnnotation.entries) {
if (hasAnnotationOrInsideAnnotatedClass(annotation.classId, session)) { if (hasAnnotationOrInsideAnnotatedClass(annotation.classId, session)) {
return true 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 * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* that can be found in the license/LICENSE.txt file. * 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 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 { override fun toString(): String {
val result = StringBuilder() val result = StringBuilder()
var firstAppend = true var firstAppend = true
for (value in ModifierFlag.Values) { for (value in ModifierFlag.entries) {
if (hasFlag(value) && value != ModifierFlag.NONE) { if (hasFlag(value) && value != ModifierFlag.NONE) {
if (firstAppend) { if (firstAppend) {
firstAppend = false 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. * 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); REIFICATION_REIFIED(1L shl 36);
companion object { companion object {
val Values = values()
val ElementTypeToModifierFlagMap: Map<IElementType, ModifierFlag> = mutableMapOf( val ElementTypeToModifierFlagMap: Map<IElementType, ModifierFlag> = mutableMapOf(
// Class // Class
KtTokens.ENUM_KEYWORD to CLASS_ENUM, 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. * 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. * 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> { ): List<T> {
@Suppress("NAME_SHADOWING") @Suppress("NAME_SHADOWING")
val scopeSession = scopeSession ?: ScopeSession() val scopeSession = scopeSession ?: ScopeSession()
val phases = FirResolvePhase.values().filter { val phases = FirResolvePhase.entries.filter {
!it.noProcessor !it.noProcessor
} }
return phases.map { it.creator(scopeSession) } return phases.map { it.creator(scopeSession) }
} }
@@ -183,8 +183,8 @@ enum class FirResolvePhase(val noProcessor: Boolean = false) {
*/ */
BODY_RESOLVE; BODY_RESOLVE;
val next: FirResolvePhase get() = values()[ordinal + 1] val next: FirResolvePhase get() = entries[ordinal + 1]
val previous: FirResolvePhase get() = values()[ordinal - 1] val previous: FirResolvePhase get() = entries[ordinal - 1]
companion object { companion object {
// Short-cut // Short-cut
@@ -39,7 +39,7 @@ class FirResolvedToPhaseState private constructor(
override val resolvePhase: FirResolvePhase override val resolvePhase: FirResolvePhase
) : FirResolveState() { ) : FirResolveState() {
companion object { 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] operator fun invoke(phase: FirResolvePhase) = phases[phase.ordinal]
} }
@@ -76,7 +76,7 @@ class FirInProcessOfResolvingToPhaseStateWithoutBarrier private constructor(
override val resolvingTo: FirResolvePhase override val resolvingTo: FirResolvePhase
) : FirInProcessOfResolvingToPhaseState() { ) : FirInProcessOfResolvingToPhaseState() {
companion object { companion object {
private val phases: List<FirInProcessOfResolvingToPhaseState> = FirResolvePhase.values() private val phases: List<FirInProcessOfResolvingToPhaseState> = FirResolvePhase.entries
.drop(1) // drop FirResolvePhase.RAW_FIR phase .drop(1) // drop FirResolvePhase.RAW_FIR phase
.map(::FirInProcessOfResolvingToPhaseStateWithoutBarrier) .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. * 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_0] = JvmMetadataVersion.INSTANCE
this[LanguageVersion.KOTLIN_2_1] = JvmMetadataVersion(2, 1, 0) 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 " + "Please add mappings from the missing LanguageVersion instances to the corresponding JvmMetadataVersion " +
"in `LANGUAGE_TO_METADATA_VERSION`" "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. * 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 { 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? { 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. * 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) { if (argumentsExpression != null) {
val specialFunctionName = requireNotNull( val specialFunctionName = requireNotNull(
ControlStructureTypingUtils.ResolveConstruct.values().find { specialFunction -> ControlStructureTypingUtils.ResolveConstruct.entries.find { specialFunction ->
specialFunction.specialFunctionName == resolvedAtom.candidateDescriptor.name specialFunction.specialFunctionName == resolvedAtom.candidateDescriptor.name
} }
) { "Unsupported special construct: ${resolvedAtom.candidateDescriptor.name} not found in special construct names" } ) { "Unsupported special construct: ${resolvedAtom.candidateDescriptor.name} not found in special construct names" }
@@ -918,7 +918,7 @@ class DiagnosticReporterByTrackingStrategy(
} }
if (atom !is ResolvedCallAtom) return false if (atom !is ResolvedCallAtom) return false
return ControlStructureTypingUtils.ResolveConstruct.values().any { specialFunction -> return ControlStructureTypingUtils.ResolveConstruct.entries.any { specialFunction ->
specialFunction.specialFunctionName == atom.candidateDescriptor.name 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. * 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.BindingContext
import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil import org.jetbrains.kotlin.resolve.FunctionDescriptorUtil
import org.jetbrains.kotlin.resolve.TemporaryBindingTrace 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.CallCandidateResolutionContext
import org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT import org.jetbrains.kotlin.resolve.calls.context.ContextDependency.INDEPENDENT
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext 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.ConstraintPositionKind.VALUE_PARAMETER_POSITION
import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ValidityConstraintForConstituentType import org.jetbrains.kotlin.resolve.calls.inference.constraintPosition.ValidityConstraintForConstituentType
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall 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
import org.jetbrains.kotlin.resolve.calls.results.ResolutionStatus.INCOMPLETE_TYPE_INFERENCE 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.results.ResolutionStatus.OTHER_ERROR
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory 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.isFunctionForExpectTypeFromCastFeature
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
import org.jetbrains.kotlin.types.* 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.expressions.ExpressionTypingUtils
import org.jetbrains.kotlin.types.typeUtil.makeNullable 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( class GenericCandidateResolver(
private val argumentTypeResolver: ArgumentTypeResolver, 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. * 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 charSequence = getClass(Name.identifier("CharSequence"), "kotlin")
val string = getClass(Name.identifier("String"), "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") val iteratorClass = getClass(Name.identifier(type.typeName.asString() + "Iterator"), "kotlin", "collections")
type to iteratorClass 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. * 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 jsArrayIteratorFunction = getInternalFunction("arrayIterator")
val jsPrimitiveArrayIteratorFunctions = 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 jsClass = getInternalFunction("jsClassIntrinsic")
val arrayLiteral: IrSimpleFunctionSymbol = getInternalFunction("arrayLiteral") val arrayLiteral: IrSimpleFunctionSymbol = getInternalFunction("arrayLiteral")
@@ -321,14 +321,14 @@ class JsIntrinsics(private val irBuiltIns: IrBuiltIns, val context: JsIrBackendC
) )
val primitiveToSizeConstructor = val primitiveToSizeConstructor =
PrimitiveType.values().associate { type -> PrimitiveType.entries.associate { type ->
type to (primitiveToTypedArrayMap[type]?.let { type to (primitiveToTypedArrayMap[type]?.let {
getInternalFunction("${it.toLowerCaseAsciiOnly()}Array") getInternalFunction("${it.toLowerCaseAsciiOnly()}Array")
} ?: getInternalFunction("${type.typeName.asString().toLowerCaseAsciiOnly()}Array")) } ?: getInternalFunction("${type.typeName.asString().toLowerCaseAsciiOnly()}Array"))
} }
val primitiveToLiteralConstructor = val primitiveToLiteralConstructor =
PrimitiveType.values().associate { type -> PrimitiveType.entries.associate { type ->
type to (primitiveToTypedArrayMap[type]?.let { type to (primitiveToTypedArrayMap[type]?.let {
getInternalFunction("${it.toLowerCaseAsciiOnly()}ArrayOf") getInternalFunction("${it.toLowerCaseAsciiOnly()}ArrayOf")
} ?: getInternalFunction("${type.typeName.asString().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. * 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 sideEffectKindValues get() = SideEffectKind.entries
private val jsBinaryOperatorValues = JsBinaryOperator.values() private val jsBinaryOperatorValues get() = JsBinaryOperator.entries
private val jsUnaryOperatorValues = JsUnaryOperator.values() private val jsUnaryOperatorValues get() = JsUnaryOperator.entries
private val jsFunctionModifiersValues = JsFunction.Modifier.values() private val jsFunctionModifiersValues get() = JsFunction.Modifier.entries
private fun readExpression(): JsExpression { private fun readExpression(): JsExpression {
return withComments { 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 { private fun readName(): JsName {
val identifier = stringTable[readInt()] 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. * 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> = 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() .map { name -> name.toLowerCaseAsciiOnly() + "ArrayOf" }.toSet()
internal const val ARRAY_OF_NAME = "arrayOf" 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. * 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 booleanArray = builtIns.getPrimitiveArrayClassDescriptor(PrimitiveType.BOOLEAN).toIrSymbol()
override val primitiveArraysToPrimitiveTypes = 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 primitiveTypesToPrimitiveArrays = primitiveArraysToPrimitiveTypes.map { (k, v) -> v to k }.toMap()
override val primitiveArrayElementTypes = primitiveArraysToPrimitiveTypes.mapValues { primitiveTypeToIrType[it.value] } override val primitiveArrayElementTypes = primitiveArraysToPrimitiveTypes.mapValues { primitiveTypeToIrType[it.value] }
override val primitiveArrayForType = primitiveArrayElementTypes.asSequence().associate { it.value to it.key } override val primitiveArrayForType = primitiveArrayElementTypes.asSequence().associate { it.value to it.key }
override val unsignedTypesToUnsignedArrays: Map<UnsignedType, IrClassSymbol> = override val unsignedTypesToUnsignedArrays: Map<UnsignedType, IrClassSymbol> =
UnsignedType.values().mapNotNull { unsignedType -> UnsignedType.entries.mapNotNull { unsignedType ->
val array = builtIns.builtInsModule.findClassAcrossModuleDependencies(unsignedType.arrayClassId)?.toIrSymbol() val array = builtIns.builtInsModule.findClassAcrossModuleDependencies(unsignedType.arrayClassId)?.toIrSymbol()
if (array == null) null else unsignedType to array if (array == null) null else unsignedType to array
}.toMap() }.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. * 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 val DEFAULT = ENABLE
fun resolveMode(key: String): PartialLinkageMode? = 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 val DEFAULT = INFO
fun resolveLogLevel(key: String): PartialLinkageLogLevel? = 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. * 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> = private val idSignatureToPrimitiveType: Map<IdSignature.CommonSignature, PrimitiveType> =
PrimitiveType.values().associateBy { PrimitiveType.entries.associateBy {
getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, it.typeName.asString()) getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, it.typeName.asString())
} }
private val shortNameToPrimitiveType: Map<Name, PrimitiveType> = private val shortNameToPrimitiveType: Map<Name, PrimitiveType> =
PrimitiveType.values().associateBy(PrimitiveType::typeName) PrimitiveType.entries.associateBy(PrimitiveType::typeName)
private val idSignatureToUnsignedType: Map<IdSignature.CommonSignature, UnsignedType> = private val idSignatureToUnsignedType: Map<IdSignature.CommonSignature, UnsignedType> =
UnsignedType.values().associateBy { UnsignedType.entries.associateBy {
getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, it.typeName.asString()) getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, it.typeName.asString())
} }
private val shortNameToUnsignedType: Map<Name, UnsignedType> = private val shortNameToUnsignedType: Map<Name, UnsignedType> =
UnsignedType.values().associateBy(UnsignedType::typeName) UnsignedType.entries.associateBy(UnsignedType::typeName)
val primitiveArrayTypesSignatures: Map<PrimitiveType, IdSignature.CommonSignature> = val primitiveArrayTypesSignatures: Map<PrimitiveType, IdSignature.CommonSignature> =
PrimitiveType.values().associateWith { PrimitiveType.entries.associateWith {
getPublicSignature(StandardNames.BUILT_INS_PACKAGE_FQ_NAME, "${it.typeName.asString()}Array") 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. * 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('.') val nameSegments: List<String> get() = declarationFqName.split('.')
private fun adaptMask(old: Long): Long = 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)) if (!f.recursive) a or (old and (1L shl f.ordinal))
else a 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. * 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 { buildSet {
this += permittedAnnotationArrayParameterSymbols this += permittedAnnotationArrayParameterSymbols
PrimitiveType.values().forEach { PrimitiveType.entries.forEach {
addIfNotNull(builtIns.findClass(it.typeName, BUILT_INS_PACKAGE_FQ_NAME)) // kotlin.<primitive> 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 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.typeName, BUILT_INS_PACKAGE_FQ_NAME)) // kotlin.U<signed>
addIfNotNull(builtIns.findClass(it.arrayClassId.shortClassName, BUILT_INS_PACKAGE_FQ_NAME)) // kotlin.U<signed>Array 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. * 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 signatureId: Int get() = (code ushr 8).toInt()
val kind: SymbolKind val kind: SymbolKind
get() = SymbolKind.values()[symbolKindId()] get() = SymbolKind.entries[symbolKindId()]
companion object { companion object {
fun encode(kind: SymbolKind, signatureId: Int): Long { 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. * 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 val variance: Variance
get() { get() {
assert(!isStarProjection) assert(!isStarProjection)
return Variance.values()[varianceId()] return Variance.entries[varianceId()]
} }
val typeIndex: Int get() = (code ushr 2).toInt() 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. * 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 kindOrdinal = dataStream.readInt()
val value = dataStream.readName() ?: StringRef.fromString("") val value = dataStream.readName() ?: StringRef.fromString("")
val valueKind = ConstantValueKind.values()[kindOrdinal] val valueKind = ConstantValueKind.entries[kindOrdinal]
return KotlinConstantExpressionStubImpl( return KotlinConstantExpressionStubImpl(
parentStub, 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. * 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.ClassId
import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.stubs.StubUtils import org.jetbrains.kotlin.psi.stubs.StubUtils
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
enum class KotlinConstantValueKind { enum class KotlinConstantValueKind {
NULL, BOOLEAN, CHAR, BYTE, SHORT, INT, LONG, DOUBLE, FLOAT, ENUM, KCLASS, STRING, ARRAY, UBYTE, USHORT, UINT, ULONG, ANNO; 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<*>? { fun createConstantValue(dataStream: StubInputStream): ConstantValue<*>? {
val kind = dataStream.readInt() val kind = dataStream.readInt()
if (kind == -1) return null if (kind == -1) return null
return when (KotlinConstantValueKind.values()[kind]) { return when (KotlinConstantValueKind.entries[kind]) {
KotlinConstantValueKind.NULL -> NullValue KotlinConstantValueKind.NULL -> NullValue
KotlinConstantValueKind.BOOLEAN -> BooleanValue(dataStream.readBoolean()) KotlinConstantValueKind.BOOLEAN -> BooleanValue(dataStream.readBoolean())
KotlinConstantValueKind.CHAR -> CharValue(dataStream.readChar()) 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. * 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 { CALLS {
override fun deserialize(dataStream: StubInputStream): KtCallsEffectDeclaration<KotlinTypeBean, Nothing?> { override fun deserialize(dataStream: StubInputStream): KtCallsEffectDeclaration<KotlinTypeBean, Nothing?> {
val declaration = PARAMETER_REFERENCE.deserialize(dataStream) val declaration = PARAMETER_REFERENCE.deserialize(dataStream)
val range = EventOccurrencesRange.values()[dataStream.readInt()] val range = EventOccurrencesRange.entries[dataStream.readInt()]
return KtCallsEffectDeclaration(declaration as KtValueParameterReference, range) return KtCallsEffectDeclaration(declaration as KtValueParameterReference, range)
} }
}, },
@@ -36,8 +36,8 @@ enum class KotlinContractEffectType {
}, },
CONDITIONAL { CONDITIONAL {
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> { override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
val descriptionElement = values()[dataStream.readInt()].deserialize(dataStream) val descriptionElement = entries[dataStream.readInt()].deserialize(dataStream)
val condition = values()[dataStream.readInt()].deserialize(dataStream) val condition = entries[dataStream.readInt()].deserialize(dataStream)
return KtConditionalEffectDeclaration( return KtConditionalEffectDeclaration(
descriptionElement as KtEffectDeclaration, descriptionElement as KtEffectDeclaration,
condition as KtBooleanExpression condition as KtBooleanExpression
@@ -63,14 +63,14 @@ enum class KotlinContractEffectType {
}, },
NOT { NOT {
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> { 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 { BOOLEAN_LOGIC {
override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> { override fun deserialize(dataStream: StubInputStream): KtContractDescriptionElement<KotlinTypeBean, Nothing?> {
val kind = if (dataStream.readBoolean()) LogicOperationKind.AND else LogicOperationKind.OR val kind = if (dataStream.readBoolean()) LogicOperationKind.AND else LogicOperationKind.OR
val left = values()[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression val left = entries[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
val right = values()[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression val right = entries[dataStream.readInt()].deserialize(dataStream) as KtBooleanExpression
return KtBinaryLogicExpression(left, right, kind) return KtBinaryLogicExpression(left, right, kind)
} }
}, },
@@ -1,17 +1,6 @@
/* /*
* Copyright 2010-2015 JetBrains s.r.o. * 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.
* 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.
*/ */
package org.jetbrains.kotlin.psi.stubs.impl package org.jetbrains.kotlin.psi.stubs.impl
@@ -70,7 +59,7 @@ class KotlinFunctionStubImpl(
val effects = mutableListOf<KtContractDescriptionElement<KotlinTypeBean, Nothing?>>() val effects = mutableListOf<KtContractDescriptionElement<KotlinTypeBean, Nothing?>>()
val count: Int = dataStream.readInt() val count: Int = dataStream.readInt()
for (i in 0 until count) { 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)) effects.add(effectType.deserialize(dataStream))
} }
return effects 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. * 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 package org.jetbrains.kotlin.test.services.impl
import org.jetbrains.kotlin.config.JvmTarget import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.JsPlatform import org.jetbrains.kotlin.platform.JsPlatform
import org.jetbrains.kotlin.platform.TargetPlatform
import org.jetbrains.kotlin.platform.js.JsPlatforms import org.jetbrains.kotlin.platform.js.JsPlatforms
import org.jetbrains.kotlin.platform.jvm.JdkPlatform import org.jetbrains.kotlin.platform.jvm.JdkPlatform
import org.jetbrains.kotlin.platform.konan.NativePlatform import org.jetbrains.kotlin.platform.konan.NativePlatform
@@ -34,8 +34,8 @@ object TargetPlatformParser {
val target = when { val target = when {
platformString == JVM -> JvmTarget.DEFAULT platformString == JVM -> JvmTarget.DEFAULT
!platformString.startsWith(JDK) -> return null !platformString.startsWith(JDK) -> return null
else -> JvmTarget.values().find { it.name == platformString } else -> JvmTarget.entries.find { it.name == platformString }
?: error("JvmTarget \"$platformString\" not found.\nAvailable targets: ${JvmTarget.values().joinToArrayString()}") ?: error("JvmTarget \"$platformString\" not found.\nAvailable targets: ${JvmTarget.entries.joinToArrayString()}")
} }
return JdkPlatform(target) 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. * 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?) { 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 { postfixesOfFilesToCheck.forEach {
if (File("$filePathPrefix.${it.postfix}.txt").exists()) 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. * 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 name = matcher.group(2)
val feature = LanguageFeature.fromString(name) ?: throw AssertionError( val feature = LanguageFeature.fromString(name) ?: throw AssertionError(
"Language feature not found, please check spelling: $name\n" + "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) { if (values.put(feature, mode) != null) {
Assert.fail("Duplicate entry for the language feature: $name") 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. * 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"); INFRASTRUCTURE_ERROR("infrastructure");
companion object { companion object {
private val map = values().associateBy(TestsExceptionType::postfix) private val map = entries.associateBy(TestsExceptionType::postfix)
fun fromValue(type: String) = map[type] 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. * 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() 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) { if (expectedState != null) {
expectedFileStats[expectedState.str] = getOpArgs().toSet() expectedFileStats[expectedState.str] = getOpArgs().toSet()
} else { } 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 * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* that can be found in the license/LICENSE.txt file. * 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 package org.jetbrains.kotlin.spec.consistency
@@ -26,7 +26,7 @@ class SpecTestsConsistencyTest : TestCase() {
fun getTestFiles(): Stream<String> { fun getTestFiles(): Stream<String> {
val testFiles = mutableListOf<String>() val testFiles = mutableListOf<String>()
TestArea.values().forEach { testArea -> TestArea.entries.forEach { testArea ->
val testDataPath = val testDataPath =
"${GeneralConfiguration.SPEC_TESTDATA_PATH}/${testArea.testDataPath}/${SpecTestLinkedType.LINKED.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 * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* that can be found in the license/LICENSE.txt file. * 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 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.LinkedSpecTestFileInfoElementType
import org.jetbrains.kotlin.spec.utils.models.NotLinkedSpecTestFileInfoElementType import org.jetbrains.kotlin.spec.utils.models.NotLinkedSpecTestFileInfoElementType
import org.jetbrains.kotlin.spec.utils.parsers.BasePatterns 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.LinkedSpecTestPatterns
import org.jetbrains.kotlin.spec.utils.parsers.NotLinkedSpecTestPatterns import org.jetbrains.kotlin.spec.utils.parsers.NotLinkedSpecTestPatterns
import org.jetbrains.kotlin.spec.utils.parsers.CommonParser.withSpaces
import java.util.* import java.util.*
import java.util.regex.Matcher import java.util.regex.Matcher
import java.util.regex.Pattern import java.util.regex.Pattern
@@ -27,8 +27,8 @@ enum class TestType(val type: String) {
NEGATIVE("neg"); NEGATIVE("neg");
companion object { companion object {
private val map = values().associateBy(TestType::type) private val map = entries.associateBy(TestType::type)
val joinedValues = values().joinToString("|").withSpaces() val joinedValues = entries.joinToString("|").withSpaces()
fun fromValue(type: String) = map[type] fun fromValue(type: String) = map[type]
} }
@@ -51,7 +51,7 @@ enum class TestArea(val testDataPath: String) {
CODEGEN_BOX("codegen/box"); CODEGEN_BOX("codegen/box");
companion object { 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. * 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 { companion object {
private fun identifyTestArea(path: String): TestArea { private fun identifyTestArea(path: String): TestArea {
TestArea.values().forEach { TestArea.entries.forEach {
if (path.startsWith(it.testDataPath)) return it if (path.startsWith(it.testDataPath)) return it
} }
throw IllegalArgumentException("testsMap path doesn't contain test area path") 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. * 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, testOrigin: TestOrigin,
) { ) {
val isImplementationTest = testOrigin == TestOrigin.IMPLEMENTATION val isImplementationTest = testOrigin == TestOrigin.IMPLEMENTATION
TestArea.values().forEach { testArea -> TestArea.entries.forEach { testArea ->
File(testOrigin.getFilePath(testArea)).walkTopDown() File(testOrigin.getFilePath(testArea)).walkTopDown()
.forEach testFiles@{ file -> .forEach testFiles@{ file ->
if (!file.isFile || file.extension != "kt" || file.isCustomTestData) return@testFiles 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 * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
* that can be found in the license/LICENSE.txt file. * 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 package org.jetbrains.kotlin.spec.utils
@@ -42,7 +42,7 @@ object TestsStatisticCollector {
fun collect(testLinkedType: SpecTestLinkedType): Map<TestArea, SpecTestsStatElement> { fun collect(testLinkedType: SpecTestLinkedType): Map<TestArea, SpecTestsStatElement> {
val statistic = mutableMapOf<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}" val specTestsPath = "$SPEC_TESTDATA_PATH/${specTestArea.name.lowercase().replace("_", "/")}/${testLinkedType.testDataPath}"
statistic[specTestArea] = 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. * 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 unsignedNumbers = numbers.drop(1).map { it + "u" }
val allFunctions = Function.values().toList() val allFunctions = Function.entries
val rangeFunctions = allFunctions - DOWN_TO val rangeFunctions = allFunctions - DOWN_TO
generateRangeOperatorTestCases("char", allFunctions, "'1'" to "'3'", charLiterals) 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. * 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, function: Function,
extraCode: String? = null, extraCode: String? = null,
subdir: 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( private fun generateTestsForFunction(
fileName: String, 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. * 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) val KOTLIN_2_1 = createByLanguageVersion(LanguageVersion.KOTLIN_2_1)
@JvmField @JvmField
val LATEST: ApiVersion = createByLanguageVersion(LanguageVersion.values().last()) val LATEST: ApiVersion = createByLanguageVersion(LanguageVersion.entries.last())
@JvmField @JvmField
val LATEST_STABLE: ApiVersion = createByLanguageVersion(LanguageVersion.LATEST_STABLE) 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. * 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"); WARNING("warning");
companion object { 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. * 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 { companion object {
@JvmStatic @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 { companion object {
@JvmStatic @JvmStatic
fun fromVersionString(str: String?) = values().find { it.versionString == str } fun fromVersionString(str: String?) = entries.find { it.versionString == str }
@JvmStatic @JvmStatic
fun fromFullVersionString(str: String) = 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. * 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 { val allPossibleFactoryDataList: List<AnalysisApiTestConfiguratorFactoryData> = buildList {
FrontendKind.values().forEach { frontend -> FrontendKind.entries.forEach { frontend ->
TestModuleKind.values().forEach { moduleKind -> TestModuleKind.entries.forEach { moduleKind ->
AnalysisSessionMode.values().forEach { analysisSessionMode -> AnalysisSessionMode.entries.forEach { analysisSessionMode ->
AnalysisApiMode.values().forEach { analysisApiMode -> AnalysisApiMode.entries.forEach { analysisApiMode ->
add(AnalysisApiTestConfiguratorFactoryData(frontend, moduleKind, analysisSessionMode, analysisApiMode)) add(AnalysisApiTestConfiguratorFactoryData(frontend, moduleKind, analysisSessionMode, analysisApiMode))
} }
} }