From 3bed360c98fe8f466044829fc047a8ef1d297e97 Mon Sep 17 00:00:00 2001 From: Dmitry Gridin Date: Tue, 16 Apr 2019 12:12:06 +0700 Subject: [PATCH] Fix "Should be replaced with Kotlin function" warnings --- .../org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt | 2 +- .../testingUtils/incrementalModificationUtils.kt | 3 ++- .../coroutines/CoroutineTransformerMethodVisitor.kt | 3 ++- .../codegen/coroutines/processUninitializedStores.kt | 3 ++- .../codegen/inline/CoveringTryCatchNodeProcessor.kt | 3 ++- .../org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt | 5 +++-- .../org/jetbrains/kotlin/codegen/inline/MethodInliner.kt | 3 ++- .../kotlin/codegen/inline/ReifiedTypeInliner.kt | 7 ++++--- .../src/org/jetbrains/kotlin/codegen/inline/SMAP.kt | 3 ++- .../kotlin/codegen/inline/inlineCodegenUtils.kt | 8 +++++--- .../codegen/optimization/fixStack/FixStackAnalyzer.kt | 3 ++- .../optimization/fixStack/LocalVariablesManager.kt | 5 +++-- .../cli-runner/src/org/jetbrains/kotlin/runner/Main.kt | 9 +++++---- .../cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt | 3 ++- .../jetbrains/kotlin/cli/js/internal/JSStdlibLinker.kt | 3 ++- .../org/jetbrains/kotlin/daemon/KotlinCompileDaemon.kt | 3 ++- .../instructions/jumps/ConditionalJumpInstruction.kt | 2 +- .../src/org/jetbrains/kotlin/resolve/TypeResolver.kt | 5 +++-- .../jetbrains/kotlin/resolve/calls/CandidateResolver.kt | 5 +++-- .../kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt | 6 ++++-- .../kotlin/psi/KotlinStringLiteralTextEscaper.kt | 3 ++- compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt | 2 +- .../calls/inference/components/ConstraintInjector.kt | 3 ++- .../calls/inference/model/NewConstraintSystemImpl.kt | 3 ++- compiler/util/src/org/jetbrains/kotlin/utils/strings.kt | 4 ++-- .../kotlin/builtins/jvm/JavaToKotlinClassMap.kt | 2 +- .../jetbrains/kotlin/resolve/constants/constantValues.kt | 2 +- .../kotlin/types/checker/ClassicTypeSystemContext.kt | 3 ++- .../kotlin/generators/protobuf/GenerateProtoBuf.kt | 3 ++- .../kotlin/idea/formatter/KotlinSpacingBuilder.kt | 3 ++- .../kotlin/idea/framework/JsLibraryStdDetectionUtil.kt | 2 +- .../idea/completion/KotlinCompletionContributor.kt | 5 +++-- .../kotlin/idea/completion/LookupElementsCollector.kt | 3 ++- .../kotlin/idea/completion/ToFromOriginalFileMapper.kt | 3 ++- .../kotlin/idea/completion/smart/NameSimilarity.kt | 3 ++- .../src/org/jetbrains/kotlin/idea/core/generateUtil.kt | 3 ++- .../gradle/AbstractGradleMultiplatformWizardTest.kt | 2 +- .../idea/codeInsight/gradle/GradleImportingTestCase.kt | 2 +- .../idea/configuration/KotlinWithLibraryConfigurator.kt | 2 +- .../idea/debugger/KotlinFrameExtraVariablesProvider.kt | 6 ++++-- .../debugger/stepping/KotlinSteppingCommandProvider.kt | 4 +++- .../kotlin/idea/internal/KotlinBytecodeToolWindow.kt | 5 +++-- .../kotlin/idea/liveTemplates/LiveTemplatesTest.kt | 2 +- .../org/jetbrains/kotlin/console/HistoryKeyListener.kt | 6 ++++-- .../org/jetbrains/kotlin/console/ReplOutputProcessor.kt | 3 ++- .../idea/editor/fixers/KotlinCatchParameterFixer.kt | 3 ++- .../idea/editor/fixers/KotlinFunctionParametersFixer.kt | 3 ++- .../kotlin/idea/editor/fixers/MissingConditionFixer.kt | 5 +++-- .../kotlin/idea/facet/KotlinFacetCompilerPluginsTab.kt | 3 ++- .../kotlin/idea/quickfix/RenameUnresolvedReferenceFix.kt | 3 ++- .../kotlin/idea/quickfix/WrongPrimitiveLiteralFix.kt | 3 ++- .../createFromUsage/callableBuilder/CallableBuilder.kt | 3 ++- .../CreateClassFromReferenceExpressionActionFactory.kt | 2 +- .../idea/refactoring/copy/CopyKotlinDeclarationDialog.kt | 3 ++- .../kotlin/idea/refactoring/elementSelectionUtils.kt | 3 ++- .../introduceVariable/KotlinIntroduceVariableHandler.kt | 3 ++- .../introduce/ui/AbstractParameterTablePanel.kt | 4 +++- .../kotlin/idea/refactoring/kotlinRefactoringUtil.kt | 3 ++- .../kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt | 4 ++-- .../kotlin/idea/debugger/KotlinOutputChecker.kt | 3 ++- .../kotlin/idea/scratch/AbstractScratchRunActionTest.kt | 2 +- j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt | 3 ++- j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt | 3 ++- .../src/org/jetbrains/kotlin/js/naming/NameSuggestion.kt | 3 ++- .../kotlin.test/jvm/src/main/kotlin/AssertionsImpl.kt | 2 +- .../kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt | 2 +- .../jetbrains/kotlin/gradle/util/gradleRunningUtils.kt | 2 +- .../projB/src/main/kotlin/helloWorld.kt | 2 +- .../kotlin/compilerRunner/GradleKotlinCompilerWork.kt | 2 +- .../org/jetbrains/kotlin/compilerRunner/reportUtils.kt | 2 +- .../kotlin/gradle/plugin/KotlinGradleBuildServices.kt | 3 ++- .../targets/js/internal/RewriteSourceMapFilterReader.kt | 5 +++-- .../kotlinp/src/org/jetbrains/kotlin/kotlinp/Main.kt | 7 ++++--- .../jetbrains/kotlin/nj2k/conversions/ForConversion.kt | 3 ++- plugins/kapt3/kapt3-cli/src/KaptCli.kt | 3 ++- .../kotlin/kapt3/test/KotlinKapt3IntegrationTests.kt | 3 ++- .../jetbrains/kotlin/scripting/repl/ReplFromTerminal.kt | 2 +- 77 files changed, 161 insertions(+), 99 deletions(-) diff --git a/ant/src/org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt b/ant/src/org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt index 89bc532d71b..200d00a063c 100644 --- a/ant/src/org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt +++ b/ant/src/org/jetbrains/kotlin/ant/KotlinCompilerAdapter.kt @@ -129,7 +129,7 @@ class KotlinCompilerAdapter : Javac13() { } companion object { - private val KOTLIN_EXTENSIONS = Arrays.asList("kt", "kts") + private val KOTLIN_EXTENSIONS = listOf("kt", "kts") private fun filterOutKotlinSources(files: Array): Array { return files.filterNot { diff --git a/build-common/test/org/jetbrains/kotlin/incremental/testingUtils/incrementalModificationUtils.kt b/build-common/test/org/jetbrains/kotlin/incremental/testingUtils/incrementalModificationUtils.kt index ede6e3e3f96..6e19a4e8f1e 100644 --- a/build-common/test/org/jetbrains/kotlin/incremental/testingUtils/incrementalModificationUtils.kt +++ b/build-common/test/org/jetbrains/kotlin/incremental/testingUtils/incrementalModificationUtils.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.incremental.testingUtils import com.intellij.openapi.util.io.FileUtil import java.io.File import java.util.* +import kotlin.math.max private val COMMANDS = listOf("new", "touch", "delete") private val COMMANDS_AS_REGEX_PART = COMMANDS.joinToString("|") @@ -166,7 +167,7 @@ class TouchFile(path: String, private val touchPolicy: TouchPolicy) : Modificati TouchPolicy.TIMESTAMP -> { val oldLastModified = file.lastModified() //Mac OS and some versions of Linux truncate timestamp to nearest second - file.setLastModified(Math.max(System.currentTimeMillis(), oldLastModified + 1000)) + file.setLastModified(max(System.currentTimeMillis(), oldLastModified + 1000)) } TouchPolicy.CHECKSUM -> { file.appendText(" ") diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt index a8bfeb5b4de..8ab9f06e784 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/CoroutineTransformerMethodVisitor.kt @@ -34,6 +34,7 @@ import org.jetbrains.org.objectweb.asm.tree.* import org.jetbrains.org.objectweb.asm.tree.analysis.Frame import org.jetbrains.org.objectweb.asm.tree.analysis.SourceInterpreter import org.jetbrains.org.objectweb.asm.tree.analysis.SourceValue +import kotlin.math.max private const val COROUTINES_DEBUG_METADATA_VERSION = 1 @@ -628,7 +629,7 @@ class CoroutineTransformerMethodVisitor( spilledToVariableMapping.add(spilledToVariable) varsCountByType.forEach { - maxVarsCountByType[it.key] = Math.max(maxVarsCountByType[it.key] ?: 0, it.value) + maxVarsCountByType[it.key] = max(maxVarsCountByType[it.key] ?: 0, it.value) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/processUninitializedStores.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/processUninitializedStores.kt index 45f27bef086..1257b01315c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/processUninitializedStores.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/coroutines/processUninitializedStores.kt @@ -27,6 +27,7 @@ import org.jetbrains.org.objectweb.asm.tree.* import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue import org.jetbrains.org.objectweb.asm.tree.analysis.Frame import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter +import kotlin.math.max /** * In cases like: @@ -135,7 +136,7 @@ class UninitializedStoresProcessor( nextVarIndex += type.size storedTypes.add(type) } - methodNode.maxLocals = Math.max(methodNode.maxLocals, nextVarIndex) + methodNode.maxLocals = max(methodNode.maxLocals, nextVarIndex) methodNode.instructions.insertBefore(insn, insnListOf( TypeInsnNode(Opcodes.NEW, newInsn.desc), diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/CoveringTryCatchNodeProcessor.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/CoveringTryCatchNodeProcessor.kt index 6becd65da34..fa573b97522 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/CoveringTryCatchNodeProcessor.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/CoveringTryCatchNodeProcessor.kt @@ -22,6 +22,7 @@ import org.jetbrains.org.objectweb.asm.tree.* import java.util.* import kotlin.collections.HashSet import kotlin.collections.LinkedHashSet +import kotlin.math.max abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) { val tryBlocksMetaInfo: IntervalMetaInfo = IntervalMetaInfo(this) @@ -42,7 +43,7 @@ abstract class CoveringTryCatchNodeProcessor(parameterSize: Int) { if (curInstr is VarInsnNode || curInstr is IincInsnNode) { val argSize = getLoadStoreArgSize(curInstr.opcode) val varIndex = if (curInstr is VarInsnNode) curInstr.`var` else (curInstr as IincInsnNode).`var` - nextFreeLocalIndex = Math.max(nextFreeLocalIndex, varIndex + argSize) + nextFreeLocalIndex = max(nextFreeLocalIndex, varIndex + argSize) } if (curInstr is LabelNode) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt index b831a40c417..7e29a3499f9 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/InlineCodegen.kt @@ -51,6 +51,7 @@ import org.jetbrains.org.objectweb.asm.commons.Method import org.jetbrains.org.objectweb.asm.tree.* import java.util.* import kotlin.collections.HashSet +import kotlin.math.max abstract class InlineCodegen( protected val codegen: T, @@ -340,9 +341,9 @@ abstract class InlineCodegen( var marker = -1 val intervals = processor.localVarsMetaInfo.currentIntervals for (interval in intervals) { - marker = Math.max(interval.node.index + 1, marker) + marker = max(interval.node.index + 1, marker) } - while (frameMap.currentSize < Math.max(processor.nextFreeLocalIndex, offsetForFinallyLocalVar + marker)) { + while (frameMap.currentSize < max(processor.nextFreeLocalIndex, offsetForFinallyLocalVar + marker)) { frameMap.enterTemp(Type.INT_TYPE) } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt index 5bc71e90407..ac3bd9c9990 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/MethodInliner.kt @@ -38,6 +38,7 @@ import org.jetbrains.org.objectweb.asm.tree.* import org.jetbrains.org.objectweb.asm.tree.analysis.* import org.jetbrains.org.objectweb.asm.util.Printer import java.util.* +import kotlin.math.max class MethodInliner( private val node: MethodNode, @@ -259,7 +260,7 @@ class MethodInliner( val erasedInvokeFunction = ClosureCodegen.getErasedInvokeFunction(actualInvokeDescriptor) val invokeParameters = erasedInvokeFunction.valueParameters - val valueParamShift = Math.max(nextLocalIndex, markerShift)//NB: don't inline cause it changes + val valueParamShift = max(nextLocalIndex, markerShift)//NB: don't inline cause it changes putStackValuesIntoLocalsForLambdaOnInvoke( listOf(*info.invokeMethod.argumentTypes), valueParameters, invokeParameters, valueParamShift, this, coroutineDesc ) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt index 18626791afa..c2824c093c4 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/ReifiedTypeInliner.kt @@ -32,6 +32,7 @@ import org.jetbrains.org.objectweb.asm.Opcodes import org.jetbrains.org.objectweb.asm.Type import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter import org.jetbrains.org.objectweb.asm.tree.* +import kotlin.math.max class ReificationArgument( val parameterName: String, val nullable: Boolean, private val arrayDepth: Int @@ -194,7 +195,7 @@ class ReifiedTypeInliner( instructions.remove(stubCheckcast) // TODO: refine max stack calculation (it's not always as big as +4) - maxStackSize = Math.max(maxStackSize, 4) + maxStackSize = max(maxStackSize, 4) return true } @@ -214,7 +215,7 @@ class ReifiedTypeInliner( instructions.remove(stubInstanceOf) // TODO: refine max stack calculation (it's not always as big as +2) - maxStackSize = Math.max(maxStackSize, 2) + maxStackSize = max(maxStackSize, 2) return true } @@ -229,7 +230,7 @@ class ReifiedTypeInliner( instructions.insert(insn, newMethodNode.instructions) instructions.remove(stubConstNull) - maxStackSize = Math.max(maxStackSize, stackSize) + maxStackSize = max(maxStackSize, stackSize) return true } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt index 8c8600281e0..1c9a2149eb3 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/SMAP.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.FILE_SECTION import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.LINE_SECTION import org.jetbrains.kotlin.codegen.inline.SMAP.Companion.STRATA_SECTION import java.util.* +import kotlin.math.max const val KOTLIN_STRATA_NAME = "Kotlin" const val KOTLIN_DEBUG_STRATA_NAME = "KotlinDebug" @@ -217,7 +218,7 @@ open class DefaultSourceMapper(val sourceInfo: SourceInfo) : SourceMapper { val newFileMapping = getOrRegisterNewSource(fileMapping.name, fileMapping.path) fileMapping.lineMappings.forEach { newFileMapping.mapNewInterval(it.source, it.dest, it.range) - maxUsedValue = Math.max(it.maxDest, maxUsedValue) + maxUsedValue = max(it.maxDest, maxUsedValue) } } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/inlineCodegenUtils.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/inlineCodegenUtils.kt index 6fb414515f4..3f686929936 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/inlineCodegenUtils.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/inline/inlineCodegenUtils.kt @@ -47,6 +47,8 @@ import org.jetbrains.org.objectweb.asm.util.Textifier import org.jetbrains.org.objectweb.asm.util.TraceMethodVisitor import java.io.PrintWriter import java.io.StringWriter +import kotlin.math.max +import kotlin.math.min const val GENERATE_SMAP = true const val NUMBERED_FUNCTION_PREFIX = "kotlin/jvm/functions/Function" @@ -121,8 +123,8 @@ internal fun getMethodNode( return object : MethodNode(Opcodes.API_VERSION, access, name, desc, signature, exceptions) { override fun visitLineNumber(line: Int, start: Label) { super.visitLineNumber(line, start) - lines[0] = Math.min(lines[0], line) - lines[1] = Math.max(lines[1], line) + lines[0] = min(lines[0], line) + lines[1] = max(lines[1], line) } }.also { node = it @@ -509,7 +511,7 @@ private fun getIndexAfterLastMarker(node: MethodNode): Int { var result = -1 for (variable in node.localVariables) { if (isFakeLocalVariableForInline(variable.name)) { - result = Math.max(result, variable.index + 1) + result = max(result, variable.index + 1) } } return result diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt index 9f1713363ac..bfbc421a54c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/FixStackAnalyzer.kt @@ -31,6 +31,7 @@ import org.jetbrains.org.objectweb.asm.tree.MethodNode import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue import org.jetbrains.org.objectweb.asm.tree.analysis.Frame import org.jetbrains.org.objectweb.asm.tree.analysis.Interpreter +import kotlin.math.max internal class FixStackAnalyzer( owner: String, @@ -133,7 +134,7 @@ internal class FixStackAnalyzer( super.push(value) } else { extraStack.add(value) - maxExtraStackSize = Math.max(maxExtraStackSize, extraStack.size) + maxExtraStackSize = max(maxExtraStackSize, extraStack.size) } } diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt index 7a1d3bb5082..b7aace59840 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/optimization/fixStack/LocalVariablesManager.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.codegen.optimization.fixStack import org.jetbrains.org.objectweb.asm.tree.AbstractInsnNode import org.jetbrains.org.objectweb.asm.tree.MethodNode import org.jetbrains.org.objectweb.asm.tree.analysis.BasicValue +import kotlin.math.max internal class LocalVariablesManager(val context: FixStackContext, val methodNode: MethodNode) { private class AllocatedHandle(val savedStackDescriptor: SavedStackDescriptor, var numRestoreMarkers: Int) { @@ -35,7 +36,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod private val allocatedHandles = hashMapOf() private fun updateMaxLocals(newValue: Int) { - methodNode.maxLocals = Math.max(methodNode.maxLocals, newValue) + methodNode.maxLocals = max(methodNode.maxLocals, newValue) } fun allocateVariablesForSaveStackMarker(saveStackMarker: AbstractInsnNode, savedStackValues: List): SavedStackDescriptor { @@ -67,7 +68,7 @@ internal class LocalVariablesManager(val context: FixStackContext, val methodNod private fun getFirstUnusedLocalVariableIndex(): Int = allocatedHandles.values.fold(initialMaxLocals) { index, handle -> - Math.max(index, handle.savedStackDescriptor.firstUnusedLocalVarIndex) + max(index, handle.savedStackDescriptor.firstUnusedLocalVarIndex) } fun markRestoreStackMarkerEmitted(restoreStackMarker: AbstractInsnNode) { diff --git a/compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt b/compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt index 61302222522..a800c045546 100644 --- a/compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt +++ b/compiler/cli/cli-runner/src/org/jetbrains/kotlin/runner/Main.kt @@ -20,6 +20,7 @@ import java.io.File import java.io.FileNotFoundException import java.net.URL import java.util.* +import kotlin.system.exitProcess object Main { private val KOTLIN_HOME: File @@ -28,7 +29,7 @@ object Main { val home = System.getProperty("kotlin.home") if (home == null) { System.err.println("error: no kotlin.home system property was passed") - System.exit(1) + exitProcess(1) } KOTLIN_HOME = File(home) } @@ -120,7 +121,7 @@ object Main { } catch (e: RunnerException) { System.err.println("error: " + e.message) - System.exit(1) + exitProcess(1) } } @@ -143,7 +144,7 @@ where command may be one of: -version Display Kotlin version -help (-h) Print a synopsis of options """) - System.exit(0) + exitProcess(0) } private fun printVersionAndExit() { @@ -155,6 +156,6 @@ where command may be one of: } println("Kotlin version " + version + " (JRE " + System.getProperty("java.runtime.version") + ")") - System.exit(0) + exitProcess(0) } } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt index c41c184e9a2..c4b978ef2e8 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/common/CLITool.kt @@ -33,6 +33,7 @@ import java.io.PrintStream import java.net.URL import java.net.URLConnection import java.util.function.Predicate +import kotlin.system.exitProcess abstract class CLITool { fun exec(errStream: PrintStream, vararg args: String): ExitCode { @@ -205,7 +206,7 @@ abstract class CLITool { } val exitCode = doMainNoExit(compiler, args) if (exitCode != ExitCode.OK) { - System.exit(exitCode.code) + exitProcess(exitCode.code) } } diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/js/internal/JSStdlibLinker.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/js/internal/JSStdlibLinker.kt index da0e5cebea8..c6043787fe3 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/js/internal/JSStdlibLinker.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/js/internal/JSStdlibLinker.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder import org.jetbrains.kotlin.js.util.TextOutputImpl import java.io.File import java.io.StringReader +import kotlin.system.exitProcess fun main(args: Array) { val outputFile = File(args[0]) @@ -55,7 +56,7 @@ private fun mergeStdlibParts(outputFile: File, wrapperFile: File, baseDir: File, when (sourceMapParse) { is SourceMapError -> { System.err.println("Error parsing source map file $sourceMapFile: ${sourceMapParse.message}") - System.exit(1) + exitProcess(1) } is SourceMapSuccess -> { val sourceMap = sourceMapParse.value diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/KotlinCompileDaemon.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/KotlinCompileDaemon.kt index e6da311ab8d..caa62fc2122 100644 --- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/KotlinCompileDaemon.kt +++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/KotlinCompileDaemon.kt @@ -33,6 +33,7 @@ import java.util.* import java.util.jar.Manifest import java.util.logging.* import kotlin.concurrent.schedule +import kotlin.system.exitProcess val DAEMON_PERIODIC_CHECK_INTERVAL_MS = 1000L val DAEMON_PERIODIC_SELDOM_CHECK_INTERVAL_MS = 60000L @@ -153,7 +154,7 @@ object KotlinCompileDaemon { timer.schedule(daemonOptions.forceShutdownTimeoutMilliseconds) { cancel() log.info("force JVM shutdown") - System.exit(0) + exitProcess(0) } } else { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt index b609c6e80d8..88cc3107d92 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/cfg/pseudocode/instructions/jumps/ConditionalJumpInstruction.kt @@ -48,7 +48,7 @@ class ConditionalJumpInstruction( } override val nextInstructions: Collection - get() = Arrays.asList(nextOnFalse, nextOnTrue) + get() = listOf(nextOnFalse, nextOnTrue) override val inputValues: List get() = listOfNotNull(conditionValue) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 42b267f7dd8..4b4d750da4f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -56,6 +56,7 @@ import org.jetbrains.kotlin.types.typeUtil.containsTypeAliasParameters import org.jetbrains.kotlin.types.typeUtil.containsTypeAliases import org.jetbrains.kotlin.types.typeUtil.isArrayOfNothing import org.jetbrains.kotlin.utils.addToStdlib.safeAs +import kotlin.math.min class TypeResolver( private val annotationResolver: AnnotationResolver, @@ -699,7 +700,7 @@ class TypeResolver( var wasStatic = false val result = SmartList() - val classifierChainLastIndex = Math.min(classifierDescriptorChain.size, reversedQualifierParts.size) - 1 + val classifierChainLastIndex = min(classifierDescriptorChain.size, reversedQualifierParts.size) - 1 for (index in 0..classifierChainLastIndex) { val qualifierPart = reversedQualifierParts[index] @@ -729,7 +730,7 @@ class TypeResolver( val nonClassQualifierParts = reversedQualifierParts.subList( - Math.min(classifierChainLastIndex + 1, reversedQualifierParts.size), + min(classifierChainLastIndex + 1, reversedQualifierParts.size), reversedQualifierParts.size ) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt index 55fb2383ee9..1582dbe5787 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/CandidateResolver.kt @@ -45,6 +45,7 @@ import org.jetbrains.kotlin.types.expressions.DoubleColonExpressionResolver import org.jetbrains.kotlin.types.typeUtil.containsTypeProjectionsInTopLevelArguments import org.jetbrains.kotlin.types.typeUtil.makeNotNullable import java.util.* +import kotlin.math.min class CandidateResolver( private val argumentTypeResolver: ArgumentTypeResolver, @@ -591,7 +592,7 @@ class CandidateResolver( } val typeParameters = functionDescriptor.typeParameters - for (i in 0..Math.min(typeParameters.size, ktTypeArguments.size) - 1) { + for (i in 0..min(typeParameters.size, ktTypeArguments.size) - 1) { val typeParameterDescriptor = typeParameters[i] val typeArgument = typeArguments[i] val typeReference = ktTypeArguments[i].typeReference @@ -686,7 +687,7 @@ class CandidateResolver( // TODO do not perform substitution for type arguments multiple times val substitutedTypeArguments = typeAliasParametersSubstitutor.safeSubstitute(unsubstitutedType, Variance.INVARIANT).arguments - for (i in 0..Math.min(typeParameters.size, substitutedTypeArguments.size) - 1) { + for (i in 0..min(typeParameters.size, substitutedTypeArguments.size) - 1) { val substitutedTypeProjection = substitutedTypeArguments[i] if (substitutedTypeProjection.isStarProjection) continue diff --git a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt index 8f30d861769..894e7905aa3 100644 --- a/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt +++ b/compiler/ir/ir.psi2ir/src/org/jetbrains/kotlin/psi2ir/generators/ArgumentsGenerationUtils.kt @@ -42,6 +42,8 @@ import org.jetbrains.kotlin.resolve.calls.model.* import org.jetbrains.kotlin.resolve.scopes.receivers.* import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeSubstitutor +import kotlin.math.max +import kotlin.math.min fun StatementGenerator.generateReceiverOrNull(ktDefaultElement: KtElement, receiver: ReceiverValue?): IntermediateValue? = receiver?.let { generateReceiver(ktDefaultElement, receiver) } @@ -220,10 +222,10 @@ fun StatementGenerator.generateVarargExpressionUsing( } val varargStartOffset = varargArgument.arguments.fold(Int.MAX_VALUE) { minStartOffset, argument -> - Math.min(minStartOffset, argument.asElement().startOffsetSkippingComments) + min(minStartOffset, argument.asElement().startOffsetSkippingComments) } val varargEndOffset = varargArgument.arguments.fold(Int.MIN_VALUE) { maxEndOffset, argument -> - Math.max(maxEndOffset, argument.asElement().endOffset) + max(maxEndOffset, argument.asElement().endOffset) } val varargElementType = diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt index 4a1001c89bd..771bb5a1de6 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KotlinStringLiteralTextEscaper.kt @@ -21,6 +21,7 @@ import com.intellij.psi.LiteralTextEscaper import gnu.trove.TIntArrayList import org.jetbrains.kotlin.psi.psiUtil.getContentRange import org.jetbrains.kotlin.psi.psiUtil.isSingleQuoted +import kotlin.math.min class KotlinStringLiteralTextEscaper(host: KtStringTemplateExpression) : LiteralTextEscaper(host) { private var sourceOffsets: IntArray? = null @@ -70,7 +71,7 @@ class KotlinStringLiteralTextEscaper(host: KtStringTemplateExpression) : Literal override fun getOffsetInHost(offsetInDecoded: Int, rangeInsideHost: TextRange): Int { val offsets = sourceOffsets if (offsets == null || offsetInDecoded >= offsets.size) return -1 - return Math.min(offsets[offsetInDecoded], rangeInsideHost.length) + rangeInsideHost.startOffset + return min(offsets[offsetInDecoded], rangeInsideHost.length) + rangeInsideHost.startOffset } override fun getRelevantTextRange(): TextRange { diff --git a/compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt b/compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt index fe7cf69b56e..a3c8e8ae3f5 100644 --- a/compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt +++ b/compiler/psi/src/org/jetbrains/kotlin/psi/KtClassBody.kt @@ -33,7 +33,7 @@ class KtClassBody : KtElementImplStub>, KtDec override fun getParent() = parentByStub - override fun getDeclarations() = Arrays.asList(*getStubOrPsiChildren(DECLARATION_TYPES, KtDeclaration.ARRAY_FACTORY)) + override fun getDeclarations() = listOf(*getStubOrPsiChildren(DECLARATION_TYPES, KtDeclaration.ARRAY_FACTORY)) override fun accept(visitor: KtVisitor, data: D) = visitor.visitClassBody(this, data) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt index 219ac5631bd..d530d1ba2ad 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/components/ConstraintInjector.kt @@ -25,6 +25,7 @@ import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.NewCapturedType import org.jetbrains.kotlin.types.model.* import java.util.* +import kotlin.math.max class ConstraintInjector(val constraintIncorporator: ConstraintIncorporator, val typeApproximator: TypeApproximator) { private val ALLOWED_DEPTH_DELTA_FOR_INCORPORATION = 1 @@ -85,7 +86,7 @@ class ConstraintInjector(val constraintIncorporator: ConstraintIncorporator, val } private fun updateAllowedTypeDepth(c: Context, initialType: KotlinTypeMarker) = with(c) { - c.maxTypeDepthFromInitialConstraints = Math.max(c.maxTypeDepthFromInitialConstraints, initialType.typeDepth()) + c.maxTypeDepthFromInitialConstraints = max(c.maxTypeDepthFromInitialConstraints, initialType.typeDepth()) } private fun Context.shouldWeSkipConstraint(typeVariable: TypeVariableMarker, constraint: Constraint): Boolean { diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt index f9dc9e76415..879b0b3262d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/NewConstraintSystemImpl.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.types.checker.NewCapturedTypeConstructor import org.jetbrains.kotlin.types.model.* import org.jetbrains.kotlin.utils.SmartList import org.jetbrains.kotlin.utils.addToStdlib.cast +import kotlin.math.max class NewConstraintSystemImpl( private val constraintInjector: ConstraintInjector, @@ -173,7 +174,7 @@ class NewConstraintSystemImpl( } storage.initialConstraints.addAll(otherSystem.initialConstraints) storage.maxTypeDepthFromInitialConstraints = - Math.max(storage.maxTypeDepthFromInitialConstraints, otherSystem.maxTypeDepthFromInitialConstraints) + max(storage.maxTypeDepthFromInitialConstraints, otherSystem.maxTypeDepthFromInitialConstraints) storage.errors.addAll(otherSystem.errors) storage.fixedTypeVariables.putAll(otherSystem.fixedTypeVariables) storage.postponedTypeVariables.addAll(otherSystem.postponedTypeVariables) diff --git a/compiler/util/src/org/jetbrains/kotlin/utils/strings.kt b/compiler/util/src/org/jetbrains/kotlin/utils/strings.kt index 46b68de6b2f..3ba44d503d1 100644 --- a/compiler/util/src/org/jetbrains/kotlin/utils/strings.kt +++ b/compiler/util/src/org/jetbrains/kotlin/utils/strings.kt @@ -23,8 +23,8 @@ private val BEGIN_MARKER = "<~BEGIN~>" private val END_MARKER = "<~END~>" fun CharSequence.substringWithContext(beginIndex: Int, endIndex: Int, range: Int): String { - val start = Math.max(0, beginIndex - range) - val end = Math.min(this.length, endIndex + range) + val start = kotlin.math.max(0, beginIndex - range) + val end = kotlin.math.min(this.length, endIndex + range) val notFromBegin = start != 0 val notToEnd = end != this.length diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JavaToKotlinClassMap.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JavaToKotlinClassMap.kt index 37425ddea2c..ee1f310ff45 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JavaToKotlinClassMap.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/builtins/jvm/JavaToKotlinClassMap.kt @@ -202,7 +202,7 @@ object JavaToKotlinClassMap : PlatformToKotlinClassMap { val kotlinMutableAnalogFqName = readOnlyToMutable[kotlinAnalog.fqNameUnsafe] ?: return setOf(kotlinAnalog) - return Arrays.asList(kotlinAnalog, builtIns.getBuiltInClassByFqName(kotlinMutableAnalogFqName)) + return listOf(kotlinAnalog, builtIns.getBuiltInClassByFqName(kotlinMutableAnalogFqName)) } override fun mapPlatformClass(classDescriptor: ClassDescriptor): Collection { diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt index 245fcbe71e9..752939bea95 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/constants/constantValues.kt @@ -91,7 +91,7 @@ class CharValue(value: Char) : IntegerValueConstant(value) { //TODO: KT-8507 12.toChar() -> "\\f" '\r' -> "\\r" - else -> if (isPrintableUnicode(c)) Character.toString(c) else "?" + else -> if (isPrintableUnicode(c)) c.toString() else "?" } private fun isPrintableUnicode(c: Char): Boolean { diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt index 4bb4735fa2e..74be1735287 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/checker/ClassicTypeSystemContext.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.types.model.* import org.jetbrains.kotlin.types.model.CaptureStatus import org.jetbrains.kotlin.types.typeUtil.asTypeProjection import org.jetbrains.kotlin.types.typeUtil.contains +import kotlin.math.max interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext { override fun TypeConstructorMarker.isDenotable(): Boolean { @@ -470,7 +471,7 @@ private fun singleBestRepresentative(collection: Collection) = colle internal fun UnwrappedType.typeDepthInternal() = when (this) { is SimpleType -> typeDepthInternal() - is FlexibleType -> Math.max(lowerBound.typeDepthInternal(), upperBound.typeDepthInternal()) + is FlexibleType -> max(lowerBound.typeDepthInternal(), upperBound.typeDepthInternal()) } internal fun SimpleType.typeDepthInternal(): Int { diff --git a/generators/tests/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBuf.kt b/generators/tests/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBuf.kt index e31e67518a8..08ce35b4144 100644 --- a/generators/tests/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBuf.kt +++ b/generators/tests/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBuf.kt @@ -21,6 +21,7 @@ import com.intellij.execution.util.ExecUtil import com.intellij.util.LineSeparator import java.io.File import java.util.regex.Pattern +import kotlin.system.exitProcess // This file generates protobuf classes from formal description. // To run it, you'll need protoc (protobuf compiler) 2.6.1 installed. @@ -86,7 +87,7 @@ fun main(args: Array) { } finally { // Workaround for JVM hanging: IDEA's process handler creates thread pool - System.exit(0) + exitProcess(0) } } diff --git a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt index 460b01e1278..421728a43b2 100644 --- a/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt +++ b/idea/formatter/src/org/jetbrains/kotlin/idea/formatter/KotlinSpacingBuilder.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.KtNodeTypes import org.jetbrains.kotlin.idea.util.requireNode import org.jetbrains.kotlin.lexer.KtTokens import java.util.* +import kotlin.math.max fun CommonCodeStyleSettings.createSpaceBeforeRBrace(numSpacesOtherwise: Int, textRange: TextRange): Spacing? { return Spacing.createDependentLFSpacing(numSpacesOtherwise, numSpacesOtherwise, textRange, @@ -107,7 +108,7 @@ class KotlinSpacingBuilder(val commonCodeStyleSettings: CommonCodeStyleSettings, val dependentSpacingRule = DependentSpacingRule(Trigger.HAS_LINE_FEEDS).registerData(Anchor.MIN_LINE_FEEDS, emptyLines + 1) spacingBuilderUtil.createLineFeedDependentSpacing(numSpacesOtherwise, numSpacesOtherwise, - if (leftEndsWithComment) Math.max(1, numberOfLineFeedsOtherwise) else numberOfLineFeedsOtherwise, + if (leftEndsWithComment) max(1, numberOfLineFeedsOtherwise) else numberOfLineFeedsOtherwise, commonCodeStyleSettings.KEEP_LINE_BREAKS, commonCodeStyleSettings.KEEP_BLANK_LINES_IN_DECLARATIONS, left.textRange, diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/JsLibraryStdDetectionUtil.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/JsLibraryStdDetectionUtil.kt index 625364846e4..ae5b88639ad 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/JsLibraryStdDetectionUtil.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/framework/JsLibraryStdDetectionUtil.kt @@ -38,7 +38,7 @@ object JsLibraryStdDetectionUtil { if (library !is LibraryEx || library.isDisposed) return false if (!ignoreKind && library.effectiveKind(project) !is JSLibraryKind) return false - val classes = Arrays.asList(*library.getFiles(OrderRootType.CLASSES)) + val classes = listOf(*library.getFiles(OrderRootType.CLASSES)) return getJsStdLibJar(classes) != null } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt index f292d6a879a..6e00e8092f5 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/KotlinCompletionContributor.kt @@ -42,6 +42,7 @@ import org.jetbrains.kotlin.psi.psiUtil.* import org.jetbrains.kotlin.resolve.bindingContextUtil.getReferenceTargets import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull +import kotlin.math.max var KtFile.doNotComplete: Boolean? by UserDataProperty(Key.create("DO_NOT_COMPLETE")) @@ -71,7 +72,7 @@ class KotlinCompletionContributor : CompletionContributor() { context.replacementOffset = context.replacementOffset val offset = context.startOffset - val tokenBefore = psiFile.findElementAt(Math.max(0, offset - 1)) + val tokenBefore = psiFile.findElementAt(max(0, offset - 1)) if (offset > 0 && tokenBefore!!.node.elementType == KtTokens.REGULAR_STRING_PART && tokenBefore.text.startsWith(".")) { val prev = tokenBefore.parent.prevSibling @@ -104,7 +105,7 @@ class KotlinCompletionContributor : CompletionContributor() { ?: DEFAULT_DUMMY_IDENTIFIER } - val tokenAt = psiFile.findElementAt(Math.max(0, offset)) + val tokenAt = psiFile.findElementAt(max(0, offset)) if (tokenAt != null) { if (context.completionType == CompletionType.SMART && !isAtEndOfLine(offset, context.editor.document) /* do not use parent expression if we are at the end of line - it's probably parsed incorrectly */) { var parent = tokenAt.parent diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt index f1e6fdf4cd8..1a4651d7bbd 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementsCollector.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.idea.completion.handlers.WithExpressionPrefixInsertH import org.jetbrains.kotlin.idea.completion.handlers.WithTailInsertHandler import org.jetbrains.kotlin.idea.core.completion.DeclarationLookupObject import java.util.* +import kotlin.math.max class LookupElementsCollector( private val onFlush: () -> Unit, @@ -157,7 +158,7 @@ class LookupElementsCollector( } val matchingDegree = RealPrefixMatchingWeigher.getBestMatchingDegree(result, prefixMatcher) - bestMatchingDegree = Math.max(bestMatchingDegree, matchingDegree) + bestMatchingDegree = max(bestMatchingDegree, matchingDegree) } // used to avoid insertion of spaces before/after ',', '=' on just typing diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ToFromOriginalFileMapper.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ToFromOriginalFileMapper.kt index 585ddb10926..a009cc73d58 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ToFromOriginalFileMapper.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/ToFromOriginalFileMapper.kt @@ -21,6 +21,7 @@ import com.intellij.psi.PsiElement import com.intellij.psi.util.PsiTreeUtil import org.jetbrains.kotlin.psi.KtFile import org.jetbrains.kotlin.psi.psiUtil.startOffset +import kotlin.math.min class ToFromOriginalFileMapper private constructor( val originalFile: KtFile, @@ -49,7 +50,7 @@ class ToFromOriginalFileMapper private constructor( syntheticLength = syntheticText.length originalLength = originalText.length - val minLength = Math.min(originalLength, syntheticLength) + val minLength = min(originalLength, syntheticLength) tailLength = (0..minLength-1).firstOrNull { syntheticText[syntheticLength - it - 1] != originalText[originalLength - it - 1] } ?: minLength diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/NameSimilarity.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/NameSimilarity.kt index b741e40cb34..4a12d15f0e4 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/NameSimilarity.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/NameSimilarity.kt @@ -22,6 +22,7 @@ import com.intellij.codeInsight.lookup.WeighingContext import com.intellij.openapi.util.Key import com.intellij.psi.codeStyle.NameUtil import org.jetbrains.kotlin.idea.core.ExpectedInfo +import kotlin.math.min val NAME_SIMILARITY_KEY = Key("NAME_SIMILARITY_KEY") @@ -49,7 +50,7 @@ private fun calcNameSimilarity(name: String, expectedName: String): Int { val nonNumberWords2 = words2.filter(::isNonNumber) // count number of words matched at the end (but ignore number words - they are less important) - val minWords = Math.min(nonNumberWords1.size, nonNumberWords2.size) + val minWords = min(nonNumberWords1.size, nonNumberWords2.size) val matchedTailLength = (0..minWords-1).firstOrNull { i -> nonNumberWords1[nonNumberWords1.size - i - 1] != nonNumberWords2[nonNumberWords2.size - i - 1] } ?: minWords diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/generateUtil.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/generateUtil.kt index 280737be168..1ada43e00be 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/generateUtil.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/generateUtil.kt @@ -34,6 +34,7 @@ import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.siblings import org.jetbrains.kotlin.psi.psiUtil.startOffset import org.jetbrains.kotlin.utils.ifEmpty +import kotlin.math.min fun moveCaretIntoGeneratedElement(editor: Editor, element: PsiElement) { val project = element.project @@ -120,7 +121,7 @@ private fun moveCaretIntoGeneratedElementDocumentUnblocked(editor: Editor, eleme val start = firstInBlock.textRange!!.startOffset val end = lastInBlock.textRange!!.endOffset - editor.moveCaret(Math.min(start, end)) + editor.moveCaret(min(start, end)) if (start < end) { editor.selectionModel.setSelection(start, end) diff --git a/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/AbstractGradleMultiplatformWizardTest.kt b/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/AbstractGradleMultiplatformWizardTest.kt index b18c8000d80..f25d11b0d9a 100644 --- a/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/AbstractGradleMultiplatformWizardTest.kt +++ b/idea/idea-gradle/tests/org/jetbrains/kotlin/gradle/AbstractGradleMultiplatformWizardTest.kt @@ -261,7 +261,7 @@ abstract class AbstractGradleMultiplatformWizardTest : ProjectWizardTestCase> { - return Arrays.asList(*AbstractModelBuilderTest.SUPPORTED_GRADLE_VERSIONS) + return listOf(*AbstractModelBuilderTest.SUPPORTED_GRADLE_VERSIONS) } fun wrapperJar(): File { diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt index b487f98b3af..895fea1c309 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/configuration/KotlinWithLibraryConfigurator.kt @@ -67,7 +67,7 @@ abstract class KotlinWithLibraryConfigurator protected constructor() : KotlinPro var nonConfiguredModules = if (!ApplicationManager.getApplication().isUnitTestMode) getCanBeConfiguredModules(project, this) else - Arrays.asList(*ModuleManager.getInstance(project).modules) + listOf(*ModuleManager.getInstance(project).modules) nonConfiguredModules -= excludeModules var modulesToConfigure = nonConfiguredModules diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt index 5b2cc3c220a..80f1384f736 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/KotlinFrameExtraVariablesProvider.kt @@ -40,6 +40,8 @@ import org.jetbrains.kotlin.idea.util.application.runReadAction import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.resolve.BindingContext import java.util.* +import kotlin.math.max +import kotlin.math.min class KotlinFrameExtraVariablesProvider : FrameExtraVariablesProvider { override fun isAvailable(sourcePosition: SourcePosition, evalContext: EvaluationContext): Boolean { @@ -70,12 +72,12 @@ private fun findAdditionalExpressions(position: SourcePosition): Set limit.startOffset && shouldSkipLine(file, doc, startLine - 1)) { startLine-- } - var endLine = Math.min(limit.endOffset, line) + var endLine = min(limit.endOffset, line) while (endLine + 1 < limit.endOffset && shouldSkipLine(file, doc, endLine + 1)) { endLine++ } diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt index ffe0af03999..0be92c9f429 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/debugger/stepping/KotlinSteppingCommandProvider.kt @@ -59,6 +59,8 @@ import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCallIm import org.jetbrains.kotlin.resolve.inline.InlineUtil import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.utils.keysToMap +import kotlin.math.max +import kotlin.math.min class KotlinSteppingCommandProvider : JvmSteppingCommandProvider() { override fun getStepOverCommand( @@ -268,7 +270,7 @@ private fun findCallsOnPosition(sourcePosition: SourcePosition, filter: (KtCallE return allFilteredCalls.filter { val shouldInclude = it.getLineNumber() in linesRange if (shouldInclude) { - linesRange = Math.min(linesRange.start, it.getLineNumber())..Math.max(linesRange.endInclusive, it.getLineNumber(false)) + linesRange = min(linesRange.start, it.getLineNumber())..max(linesRange.endInclusive, it.getLineNumber(false)) } shouldInclude } diff --git a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.kt b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.kt index 6180f362312..8ae54db72c6 100644 --- a/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.kt +++ b/idea/idea-jvm/src/org/jetbrains/kotlin/idea/internal/KotlinBytecodeToolWindow.kt @@ -53,6 +53,7 @@ import java.util.* import javax.swing.JButton import javax.swing.JCheckBox import javax.swing.JPanel +import kotlin.math.min sealed class BytecodeGenerationResult { data class Bytecode(val text: String) : BytecodeGenerationResult() @@ -154,10 +155,10 @@ class KotlinBytecodeToolWindow(private val myProject: Project, private val toolW val byteCodeDocument = myEditor.document val linesRange = mapLines(byteCodeDocument.text, startLine, endLine) - val endSelectionLineIndex = Math.min(linesRange.second + 1, byteCodeDocument.lineCount) + val endSelectionLineIndex = min(linesRange.second + 1, byteCodeDocument.lineCount) val startOffset = byteCodeDocument.getLineStartOffset(linesRange.first) - val endOffset = Math.min(byteCodeDocument.getLineStartOffset(endSelectionLineIndex), byteCodeDocument.textLength) + val endOffset = min(byteCodeDocument.getLineStartOffset(endSelectionLineIndex), byteCodeDocument.textLength) myEditor.caretModel.moveToOffset(endOffset) myEditor.scrollingModel.scrollToCaret(ScrollType.MAKE_VISIBLE) diff --git a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt index bd42865b636..b38bc497914 100644 --- a/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt +++ b/idea/idea-live-templates/tests/org/jetbrains/kotlin/idea/liveTemplates/LiveTemplatesTest.kt @@ -308,7 +308,7 @@ class LiveTemplatesTest : KotlinLightCodeInsightFixtureTestCase() { } private fun assertStringItems(@NonNls vararg items: String) { - TestCase.assertEquals(Arrays.asList(*items), Arrays.asList(*itemStringsSorted)) + TestCase.assertEquals(listOf(*items), listOf(*itemStringsSorted)) } private val itemStrings: Array diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/HistoryKeyListener.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/HistoryKeyListener.kt index 70575dc40f0..008425dc691 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/HistoryKeyListener.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/HistoryKeyListener.kt @@ -23,6 +23,8 @@ import com.intellij.openapi.editor.ex.util.EditorUtil import com.intellij.openapi.project.Project import java.awt.event.KeyAdapter import java.awt.event.KeyEvent +import kotlin.math.max +import kotlin.math.min class HistoryKeyListener( private val project: Project, private val consoleEditor: EditorEx, private val history: CommandHistory @@ -73,7 +75,7 @@ class HistoryKeyListener( unfinishedCommand = document.text } - historyPos = Math.max(historyPos - 1, 0) + historyPos = max(historyPos - 1, 0) WriteCommandAction.runWriteCommandAction(project) { document.setText(history[historyPos].entryText) EditorUtil.scrollToTheEnd(consoleEditor) @@ -89,7 +91,7 @@ class HistoryKeyListener( return } - historyPos = Math.min(historyPos + 1, history.size) + historyPos = min(historyPos + 1, history.size) WriteCommandAction.runWriteCommandAction(project) { document.setText(if (historyPos == history.size) unfinishedCommand else history[historyPos].entryText) prevCaretOffset = document.textLength diff --git a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputProcessor.kt b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputProcessor.kt index 1291daa3414..5e350637d9e 100644 --- a/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputProcessor.kt +++ b/idea/idea-repl/src/org/jetbrains/kotlin/console/ReplOutputProcessor.kt @@ -35,6 +35,7 @@ import org.jetbrains.kotlin.console.gutter.ConsoleErrorRenderer import org.jetbrains.kotlin.console.gutter.ConsoleIndicatorRenderer import org.jetbrains.kotlin.console.gutter.ReplIcons import org.jetbrains.kotlin.diagnostics.Severity +import kotlin.math.max class ReplOutputProcessor( private val runner: KotlinConsoleRunner @@ -123,7 +124,7 @@ class ReplOutputProcessor( }.values.map { messages -> val highlighters = messages.map { message -> val cmdStart = lastCommandStartOffset + message.range.startOffset - val cmdEnd = lastCommandStartOffset + Math.max(message.range.endOffset, message.range.startOffset + 1) + val cmdEnd = lastCommandStartOffset + max(message.range.endOffset, message.range.startOffset + 1) val textAttributes = getAttributesForSeverity(cmdStart, cmdEnd, message.severity) historyMarkup.addRangeHighlighter( diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinCatchParameterFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinCatchParameterFixer.kt index 53ed0db17bf..756c82362ba 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinCatchParameterFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinCatchParameterFixer.kt @@ -24,6 +24,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.psi.KtCatchClause import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.startOffset +import kotlin.math.min class KotlinCatchParameterFixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, psiElement: PsiElement) { @@ -33,7 +34,7 @@ class KotlinCatchParameterFixer : SmartEnterProcessorWithFixers.Fixer() { @@ -32,7 +33,7 @@ class KotlinFunctionParametersFixer : SmartEnterProcessorWithFixers.Fixer : SmartEnterProcessorWithFixers.Fixer() { override fun apply(editor: Editor, processor: KotlinSmartEnterHandler, element: PsiElement) { @@ -35,10 +36,10 @@ abstract class MissingConditionFixer : SmartEnterProcessorWithFi var stopOffset = doc.getLineEndOffset(doc.getLineNumber(workElement.range.start)) val then = getBody(workElement) if (then != null) { - stopOffset = Math.min(stopOffset, then.range.start) + stopOffset = min(stopOffset, then.range.start) } - stopOffset = Math.min(stopOffset, workElement.range.end) + stopOffset = min(stopOffset, workElement.range.end) doc.replaceString(workElement.range.start, stopOffset, "$keyword ()") processor.registerUnresolvedError(workElement.range.start + "$keyword (".length) diff --git a/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetCompilerPluginsTab.kt b/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetCompilerPluginsTab.kt index 7449e338822..85092e9018b 100644 --- a/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetCompilerPluginsTab.kt +++ b/idea/src/org/jetbrains/kotlin/idea/facet/KotlinFacetCompilerPluginsTab.kt @@ -30,6 +30,7 @@ import javax.swing.* import javax.swing.table.AbstractTableModel import javax.swing.table.TableCellEditor import javax.swing.table.TableCellRenderer +import kotlin.math.max class KotlinFacetCompilerPluginsTab( private val configuration: KotlinFacetConfiguration, @@ -154,7 +155,7 @@ class KotlinFacetCompilerPluginsTab( val component = super.prepareRenderer(renderer, row, column) val rendererWidth = component.preferredSize.width with(getColumnModel().getColumn(column)) { - preferredWidth = Math.max(rendererWidth + intercellSpacing.width, preferredWidth) + preferredWidth = max(rendererWidth + intercellSpacing.width, preferredWidth) } return component } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/RenameUnresolvedReferenceFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/RenameUnresolvedReferenceFix.kt index 53bbc9fc5bc..c94a702206f 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/RenameUnresolvedReferenceFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/RenameUnresolvedReferenceFix.kt @@ -42,6 +42,7 @@ import org.jetbrains.kotlin.resolve.scopes.DescriptorKindFilter import org.jetbrains.kotlin.types.typeUtil.isSubtypeOf import org.jetbrains.kotlin.utils.ifEmpty import java.util.* +import kotlin.math.min object RenameUnresolvedReferenceActionFactory : KotlinSingleIntentionActionFactory() { override fun createAction(diagnostic: Diagnostic): IntentionAction? { @@ -134,7 +135,7 @@ class RenameUnresolvedReferenceFix(element: KtNameReferenceExpression): KotlinQu private class HammingComparator(private val referenceString: String, private val asString: T.() -> String) : Comparator { private fun countDifference(s1: String): Int { - return (0..Math.min(s1.lastIndex, referenceString.lastIndex)).count { s1[it] != referenceString[it] } + return (0..min(s1.lastIndex, referenceString.lastIndex)).count { s1[it] != referenceString[it] } } override fun compare(lookupItem1: T, lookupItem2: T): Int { diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/WrongPrimitiveLiteralFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/WrongPrimitiveLiteralFix.kt index 8dd613dc666..fd18d7633e4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/WrongPrimitiveLiteralFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/WrongPrimitiveLiteralFix.kt @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.typeUtil.isUnsignedNumberType +import kotlin.math.floor private val valueRanges = mapOf( KotlinBuiltIns.FQ_NAMES._byte to Byte.MIN_VALUE.toLong()..Byte.MAX_VALUE.toLong(), @@ -85,7 +86,7 @@ class WrongPrimitiveLiteralFix(element: KtConstantExpression, type: KotlinType) if (constValue is Float || constValue is Double) { val value = constValue.toDouble() - if (value != Math.floor(value)) return false + if (value != floor(value)) return false if (value !in Long.MIN_VALUE.toDouble()..Long.MAX_VALUE.toDouble()) return false } diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt index 102c19a634c..e5ca4f695d4 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/callableBuilder/CallableBuilder.kt @@ -79,6 +79,7 @@ import org.jetbrains.kotlin.types.typeUtil.isAnyOrNullableAny import org.jetbrains.kotlin.types.typeUtil.isUnit import org.jetbrains.kotlin.types.typeUtil.makeNullable import java.util.* +import kotlin.math.max /** * Represents a single choice for a type (e.g. parameter type or return type). @@ -1062,7 +1063,7 @@ internal fun placeDeclarationInContainer( else -> 1 } - return Math.max(lineBreaksNeeded - lineBreaksPresent, 0) + return max(lineBreaksNeeded - lineBreaksPresent, 0) } val actualContainer = (container as? KtClassOrObject)?.getOrCreateBody() ?: container diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromReferenceExpressionActionFactory.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromReferenceExpressionActionFactory.kt index 1b078cf9c4e..5ccb24608ad 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromReferenceExpressionActionFactory.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/createFromUsage/createClass/CreateClassFromReferenceExpressionActionFactory.kt @@ -98,7 +98,7 @@ object CreateClassFromReferenceExpressionActionFactory : CreateClassFromUsageFac val targetParents = getTargetParentsByCall(call, context).ifEmpty { return emptyList() } if (isInnerClassExpected(call)) return Collections.emptyList() - val allKinds = Arrays.asList(ClassKind.OBJECT, ClassKind.ENUM_ENTRY) + val allKinds = listOf(ClassKind.OBJECT, ClassKind.ENUM_ENTRY) val expectedType = fullCallExpr.guessTypeForClass(context, moduleDescriptor) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinDeclarationDialog.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinDeclarationDialog.kt index 32ffd7e01f4..913ad394925 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinDeclarationDialog.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/copy/CopyKotlinDeclarationDialog.kt @@ -49,6 +49,7 @@ import java.awt.Font import javax.swing.JComponent import javax.swing.JLabel import javax.swing.JPanel +import kotlin.math.max // Based on com.intellij.refactoring.copy.CopyClassDialog class CopyKotlinDeclarationDialog( @@ -97,7 +98,7 @@ class CopyKotlinDeclarationDialog( override fun createNorthPanel(): JComponent? { val qualifiedName = qualifiedName packageNameField = PackageNameReferenceEditorCombo(qualifiedName, project, RECENTS_KEY, RefactoringBundle.message("choose.destination.package")) - packageNameField.setTextFieldPreferredWidth(Math.max(qualifiedName.length + 5, 40)) + packageNameField.setTextFieldPreferredWidth(max(qualifiedName.length + 5, 40)) packageLabel.text = RefactoringBundle.message("destination.package") packageLabel.labelFor = packageNameField diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/elementSelectionUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/elementSelectionUtils.kt index 633eb25dd80..f9fa43447a5 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/elementSelectionUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/elementSelectionUtils.kt @@ -42,6 +42,7 @@ import java.util.* import javax.swing.DefaultListCellRenderer import javax.swing.DefaultListModel import javax.swing.JList +import kotlin.math.min @Throws(IntroduceRefactoringException::class) fun selectElement( @@ -237,7 +238,7 @@ private fun smartSelectElement( fun getExpressionShortText(element: KtElement): String { val text = element.renderTrimmed() val firstNewLinePos = text.indexOf('\n') - var trimmedText = text.substring(0, if (firstNewLinePos != -1) firstNewLinePos else Math.min(100, text.length)) + var trimmedText = text.substring(0, if (firstNewLinePos != -1) firstNewLinePos else min(100, text.length)) if (trimmedText.length != text.length) trimmedText += " ..." return trimmedText } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt index 915cc2a50e5..9f8617df5c9 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/KotlinIntroduceVariableHandler.kt @@ -74,6 +74,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull import org.jetbrains.kotlin.utils.ifEmpty import org.jetbrains.kotlin.utils.sure import java.util.* +import kotlin.math.min object KotlinIntroduceVariableHandler : RefactoringActionHandler { val INTRODUCE_VARIABLE = KotlinRefactoringBundle.message("introduce.variable") @@ -331,7 +332,7 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler { private fun calculateAnchor(commonParent: PsiElement, commonContainer: PsiElement, allReplaces: List): PsiElement? { if (commonParent != commonContainer) return commonParent.parentsWithSelf.firstOrNull { it.parent == commonContainer } - val startOffset = allReplaces.fold(commonContainer.endOffset) { offset, expr -> Math.min(offset, expr.substringContextOrThis.startOffset) } + val startOffset = allReplaces.fold(commonContainer.endOffset) { offset, expr -> min(offset, expr.substringContextOrThis.startOffset) } return commonContainer.allChildren.lastOrNull { it.textRange.contains(startOffset) } ?: return null } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ui/AbstractParameterTablePanel.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ui/AbstractParameterTablePanel.kt index 22b01ee93ee..87b7b426885 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ui/AbstractParameterTablePanel.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/ui/AbstractParameterTablePanel.kt @@ -30,6 +30,8 @@ import java.awt.event.ActionEvent import java.awt.event.KeyEvent import javax.swing.* import javax.swing.table.AbstractTableModel +import kotlin.math.max +import kotlin.math.min abstract class AbstractParameterTablePanel> : JPanel(BorderLayout()) { companion object { @@ -165,7 +167,7 @@ abstract class AbstractParameterTablePanel replaceListPsiAndKeepDelimiters( val oldCount = oldParameters.size val newCount = newParameters.size - val commonCount = Math.min(oldCount, newCount) + val commonCount = min(oldCount, newCount) for (i in 0 until commonCount) { oldParameters[i] = oldParameters[i].replace(newParameters[i]) as KtElement } diff --git a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt index 7d607764ce7..bcf4b2f6e97 100644 --- a/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/versions/KotlinRuntimeLibraryUtil.kt @@ -92,7 +92,7 @@ enum class LibraryJarDescriptor( RUNTIME_JAR(PathUtil.KOTLIN_JAVA_STDLIB_JAR, OrderRootType.CLASSES, true, { it.stdlibPath }) { override fun findExistingJar(library: Library): VirtualFile? { if (isExternalLibrary(library)) return null - return JavaRuntimeDetectionUtil.getRuntimeJar(Arrays.asList(*library.getFiles(OrderRootType.CLASSES))) + return JavaRuntimeDetectionUtil.getRuntimeJar(listOf(*library.getFiles(OrderRootType.CLASSES))) } }, @@ -132,7 +132,7 @@ enum class LibraryJarDescriptor( open fun findExistingJar(library: Library): VirtualFile? { if (isExternalLibrary(library)) return null - return LibraryUtils.getJarFile(Arrays.asList(*library.getFiles(orderRootType)), jarName) + return LibraryUtils.getJarFile(listOf(*library.getFiles(orderRootType)), jarName) } fun getPathInPlugin() = getPath(PathUtil.kotlinPathsForIdeaPlugin) diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinOutputChecker.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinOutputChecker.kt index eac3f6a4628..8ebfcaac3f1 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinOutputChecker.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/KotlinOutputChecker.kt @@ -16,6 +16,7 @@ import com.intellij.openapi.util.text.StringUtilRt import com.intellij.openapi.vfs.CharsetToolkit import org.junit.Assert import java.io.File +import kotlin.math.min internal class KotlinOutputChecker( private val testDir: String, @@ -79,7 +80,7 @@ internal class KotlinOutputChecker( println("actual:") println(actual) - val len = Math.min(expected.length, actual.length) + val len = min(expected.length, actual.length) if (expected.length != actual.length) { println("Text sizes differ: expected " + expected.length + " but actual: " + actual.length) } diff --git a/idea/tests/org/jetbrains/kotlin/idea/scratch/AbstractScratchRunActionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/scratch/AbstractScratchRunActionTest.kt index 61e5a80c4c2..6d2d9cfd547 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/scratch/AbstractScratchRunActionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/scratch/AbstractScratchRunActionTest.kt @@ -67,7 +67,7 @@ abstract class AbstractScratchRunActionTest : FileEditorManagerTestCase() { val outputDir = createTempDir(dirName) if (javaFiles.isNotEmpty()) { - val options = Arrays.asList("-d", outputDir.path) + val options = listOf("-d", outputDir.path) KotlinTestUtils.compileJavaFiles(javaFiles, options) } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt index e0fefb19a30..d16b74dd245 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/CodeBuilder.kt @@ -27,6 +27,7 @@ import org.jetbrains.kotlin.j2k.ast.SpacesInheritance import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.psiUtil.isAncestor import java.util.* +import kotlin.math.max fun CodeBuilder.buildList(generators: Collection<() -> T>, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder { if (generators.isNotEmpty()) { @@ -192,7 +193,7 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter: return when { isEmpty() -> other other.isEmpty() -> this - else -> Prefix(elements + other.elements, Math.max(lineBreaksBefore, other.lineBreaksBefore)) + else -> Prefix(elements + other.elements, max(lineBreaksBefore, other.lineBreaksBefore)) } } diff --git a/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt index e9fd7721bc1..6165e0f9b06 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/ForConverter.kt @@ -22,6 +22,7 @@ import com.intellij.util.IncorrectOperationException import org.jetbrains.kotlin.j2k.ast.* import org.jetbrains.kotlin.psi.psiUtil.parents import org.jetbrains.kotlin.psi.psiUtil.siblings +import kotlin.math.abs class ForConverter( private val statement: PsiForStatement, @@ -278,7 +279,7 @@ class ForConverter( val converted = codeConverter.convertExpression(bound) val sign = if (correction > 0) JavaTokenType.PLUS else JavaTokenType.MINUS - return BinaryExpression(converted, LiteralExpression(Math.abs(correction).toString()).assignNoPrototype(), Operator(sign).assignPrototype(bound)).assignNoPrototype() + return BinaryExpression(converted, LiteralExpression(abs(correction).toString()).assignNoPrototype(), Operator(sign).assignPrototype(bound)).assignNoPrototype() } private fun PsiStatement.toContinuedLoop(): PsiLoopStatement? { diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/naming/NameSuggestion.kt b/js/js.frontend/src/org/jetbrains/kotlin/js/naming/NameSuggestion.kt index 8e604f46df9..60ef0e21aa6 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/naming/NameSuggestion.kt +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/naming/NameSuggestion.kt @@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe import org.jetbrains.kotlin.resolve.descriptorUtil.isEnumValueOfMethod import java.util.* +import kotlin.math.abs /** * This class is responsible for generating names for declarations. It does not produce fully-qualified JS name, instead @@ -339,7 +340,7 @@ class NameSuggestion { } private fun mangledId(forCalculateId: String): String { - val absHashCode = Math.abs(forCalculateId.hashCode()) + val absHashCode = abs(forCalculateId.hashCode()) return if (absHashCode != 0) absHashCode.toString(Character.MAX_RADIX) else "" } diff --git a/libraries/kotlin.test/jvm/src/main/kotlin/AssertionsImpl.kt b/libraries/kotlin.test/jvm/src/main/kotlin/AssertionsImpl.kt index 9468203716f..21dddef3066 100644 --- a/libraries/kotlin.test/jvm/src/main/kotlin/AssertionsImpl.kt +++ b/libraries/kotlin.test/jvm/src/main/kotlin/AssertionsImpl.kt @@ -51,7 +51,7 @@ actual fun assertFailsWith(exceptionClass: KClass, message: S */ @InlineOnly actual inline fun todo(@Suppress("UNUSED_PARAMETER") block: () -> Unit) { - System.out.println("TODO at " + currentStackTrace()[0]) + println("TODO at " + currentStackTrace()[0]) } /** diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt index c555e04d09b..880d4526c17 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/BaseGradleIT.kt @@ -306,7 +306,7 @@ abstract class BaseGradleIT { } catch (t: Throwable) { // to prevent duplication of output if (!options.forceOutputToStdout) { - System.out.println(result.output) + println(result.output) } throw t } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/gradleRunningUtils.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/gradleRunningUtils.kt index 1efdfb01f81..51b1c09c9ad 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/gradleRunningUtils.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/kotlin/org/jetbrains/kotlin/gradle/util/gradleRunningUtils.kt @@ -37,7 +37,7 @@ fun runProcess( val sb = StringBuilder() process.inputStream!!.bufferedReader().forEachLine { if (options?.forceOutputToStdout ?: false) { - System.out.println(it) + println(it) } sb.appendln(it) } diff --git a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiprojectWithDependency/projB/src/main/kotlin/helloWorld.kt b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiprojectWithDependency/projB/src/main/kotlin/helloWorld.kt index e42a373a7b1..e8a12881e56 100644 --- a/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiprojectWithDependency/projB/src/main/kotlin/helloWorld.kt +++ b/libraries/tools/kotlin-gradle-plugin-integration-tests/src/test/resources/testProject/multiprojectWithDependency/projB/src/main/kotlin/helloWorld.kt @@ -1,7 +1,7 @@ package projB fun main(vararg args: String) { - System.out.println(projA.getInfo()) + println(projA.getInfo()) } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt index 12f003d6ed7..2522d426c9d 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/GradleKotlinCompilerWork.kt @@ -76,7 +76,7 @@ internal class GradleKotlinCompilerWork @Inject constructor( companion object { init { if (System.getProperty("org.jetbrains.kotlin.compilerRunner.GradleKotlinCompilerWork.trace.loading") == "true") { - System.out.println("Loaded GradleKotlinCompilerWork") + println("Loaded GradleKotlinCompilerWork") } } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/reportUtils.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/reportUtils.kt index da2ba929898..bece3e0b5e8 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/reportUtils.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/compilerRunner/reportUtils.kt @@ -93,7 +93,7 @@ internal fun runToolInSeparateProcess( } } else { process.inputStream!!.bufferedReader().forEachLine { - System.out.println(it) + println(it) } } diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinGradleBuildServices.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinGradleBuildServices.kt index 32ec52ba00b..1e5456c65c2 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinGradleBuildServices.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/plugin/KotlinGradleBuildServices.kt @@ -31,6 +31,7 @@ import org.jetbrains.kotlin.gradle.report.configureBuildReporter import org.jetbrains.kotlin.gradle.utils.relativeToRoot import org.jetbrains.kotlin.utils.addToStdlib.sumByLong import java.lang.management.ManagementFactory +import kotlin.math.max internal class KotlinGradleBuildServices private constructor( private val gradle: Gradle @@ -132,7 +133,7 @@ internal class KotlinGradleBuildServices private constructor( } private fun getGcCount(): Long = - ManagementFactory.getGarbageCollectorMXBeans().sumByLong { Math.max(0, it.collectionCount) } + ManagementFactory.getGarbageCollectorMXBeans().sumByLong { max(0, it.collectionCount) } private var loadedInProjectPath: String? = null diff --git a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/internal/RewriteSourceMapFilterReader.kt b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/internal/RewriteSourceMapFilterReader.kt index 8eeae52cd6b..5196548eb2b 100644 --- a/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/internal/RewriteSourceMapFilterReader.kt +++ b/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/targets/js/internal/RewriteSourceMapFilterReader.kt @@ -6,6 +6,7 @@ import com.google.gson.stream.JsonWriter import com.google.gson.stream.MalformedJsonException import org.slf4j.LoggerFactory import java.io.* +import kotlin.math.min open class RewriteSourceMapFilterReader( val input: Reader @@ -175,7 +176,7 @@ open class RewriteSourceMapFilterReader( } } - val toRead = Math.min(todo, bufferAvailable) + val toRead = min(todo, bufferAvailable) buffer.getChars(bufferReadPos, bufferReadPos + toRead, dest, destOffset) bufferReadPos += toRead destOffset += toRead @@ -201,7 +202,7 @@ open class RewriteSourceMapFilterReader( } } - val toRead = Math.min(todo, bufferAvailable) + val toRead = min(todo, bufferAvailable) bufferReadPos += toRead todo -= toRead } diff --git a/libraries/tools/kotlinp/src/org/jetbrains/kotlin/kotlinp/Main.kt b/libraries/tools/kotlinp/src/org/jetbrains/kotlin/kotlinp/Main.kt index c243da4d0ed..dd80db52252 100644 --- a/libraries/tools/kotlinp/src/org/jetbrains/kotlin/kotlinp/Main.kt +++ b/libraries/tools/kotlinp/src/org/jetbrains/kotlin/kotlinp/Main.kt @@ -7,6 +7,7 @@ package org.jetbrains.kotlin.kotlinp import java.io.File import java.io.IOException +import kotlin.system.exitProcess object Main { private fun run(args: Array) { @@ -60,7 +61,7 @@ object Main { run(args) } catch (e: KotlinpException) { System.err.println("error: " + e.message) - System.exit(1) + exitProcess(1) } } @@ -75,7 +76,7 @@ where possible options include: -help (-h) Print a synopsis of options """ ) - System.exit(0) + exitProcess(0) } private fun printVersionAndExit() { @@ -83,6 +84,6 @@ where possible options include: val version = "@snapshot@" println("Kotlin version " + version + " (JRE " + System.getProperty("java.runtime.version") + ")") - System.exit(0) + exitProcess(0) } } diff --git a/nj2k/src/org/jetbrains/kotlin/nj2k/conversions/ForConversion.kt b/nj2k/src/org/jetbrains/kotlin/nj2k/conversions/ForConversion.kt index dff74a08c25..8b0d9898e00 100644 --- a/nj2k/src/org/jetbrains/kotlin/nj2k/conversions/ForConversion.kt +++ b/nj2k/src/org/jetbrains/kotlin/nj2k/conversions/ForConversion.kt @@ -13,6 +13,7 @@ import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.nj2k.* import org.jetbrains.kotlin.nj2k.tree.* import org.jetbrains.kotlin.nj2k.tree.impl.* +import kotlin.math.abs class ForConversion(private val context: ConversionContext) : RecursiveApplicableConversionBase() { @@ -199,7 +200,7 @@ class ForConversion(private val context: ConversionContext) : RecursiveApplicabl val sign = if (correction > 0) KtTokens.PLUS else KtTokens.MINUS return kotlinBinaryExpression( bound, - JKKtLiteralExpressionImpl(Math.abs(correction).toString(), JKLiteralExpression.LiteralType.INT), + JKKtLiteralExpressionImpl(abs(correction).toString(), JKLiteralExpression.LiteralType.INT), JKKtSingleValueOperatorToken(sign), context.symbolProvider )!! diff --git a/plugins/kapt3/kapt3-cli/src/KaptCli.kt b/plugins/kapt3/kapt3-cli/src/KaptCli.kt index f123d8c0bb0..9e6a2e0815d 100644 --- a/plugins/kapt3/kapt3-cli/src/KaptCli.kt +++ b/plugins/kapt3/kapt3-cli/src/KaptCli.kt @@ -17,6 +17,7 @@ import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler import org.jetbrains.kotlin.cli.jvm.modules.isAtLeastJava9 import org.jetbrains.kotlin.kapt.cli.CliToolOption.Format.* import java.io.File +import kotlin.system.exitProcess fun main(args: Array) { val messageCollector = PrintingMessageCollector(System.err, MessageRenderer.PLAIN_RELATIVE_PATHS, false) @@ -29,7 +30,7 @@ fun main(args: Array) { val kaptTransformed = transformArgs(args.asList(), messageCollector, false) if (messageCollector.hasErrors()) { - System.exit(ExitCode.COMPILATION_ERROR.code) + exitProcess(ExitCode.COMPILATION_ERROR.code) return } diff --git a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/KotlinKapt3IntegrationTests.kt b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/KotlinKapt3IntegrationTests.kt index b0fed40a2bf..296e7a03162 100644 --- a/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/KotlinKapt3IntegrationTests.kt +++ b/plugins/kapt3/kapt3-compiler/test/org/jetbrains/kotlin/kapt3/test/KotlinKapt3IntegrationTests.kt @@ -28,6 +28,7 @@ import javax.annotation.processing.RoundEnvironment import javax.lang.model.element.ElementKind import javax.lang.model.element.ExecutableElement import javax.lang.model.element.TypeElement +import kotlin.system.exitProcess class KotlinKapt3IntegrationTests : AbstractKotlinKapt3IntegrationTest(), Java9TestLauncher { override fun test( @@ -149,7 +150,7 @@ internal class SingleJUnitTestRunner { val (className, methodName) = args.single().split('#') val request = Request.method(Class.forName(className), methodName) val result = JUnitCore().run(request) - System.exit(if (result.wasSuccessful()) 0 else 1) + exitProcess(if (result.wasSuccessful()) 0 else 1) } } } \ No newline at end of file diff --git a/plugins/scripting/scripting-compiler-impl/src/org/jetbrains/kotlin/scripting/repl/ReplFromTerminal.kt b/plugins/scripting/scripting-compiler-impl/src/org/jetbrains/kotlin/scripting/repl/ReplFromTerminal.kt index 878bdc89574..09af43e2961 100644 --- a/plugins/scripting/scripting-compiler-impl/src/org/jetbrains/kotlin/scripting/repl/ReplFromTerminal.kt +++ b/plugins/scripting/scripting-compiler-impl/src/org/jetbrains/kotlin/scripting/repl/ReplFromTerminal.kt @@ -150,7 +150,7 @@ class ReplFromTerminal( companion object { private fun splitCommand(command: String): List { - return Arrays.asList(*command.split(" ".toRegex()).dropLastWhile(String::isEmpty).toTypedArray()) + return listOf(*command.split(" ".toRegex()).dropLastWhile(String::isEmpty).toTypedArray()) } fun run(disposable: Disposable, configuration: CompilerConfiguration) {