From 744a7a83f77250941731de8b5557f806fd4ded58 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Tue, 26 Jan 2016 21:53:07 +0300 Subject: [PATCH] Cleanup RC deprecations in compiler and plugin. --- .../kotlin/codegen/ArgumentGenerator.kt | 2 +- .../codegen/context/DefaultImplsClassContext.kt | 2 +- .../jetbrains/kotlin/cli/jvm/PluginCliParser.kt | 6 +++--- .../Conditional.kt | 2 +- .../Modifications.kt | 2 +- .../Preprocessor.kt | 2 +- .../src/org/jetbrains/kotlin/container/Cache.kt | 2 +- .../kotlin/daemon/client/KotlinCompilerClient.kt | 3 ++- .../kotlin/daemon/CompileServiceImpl.kt | 3 ++- .../kotlin/daemon/LazyClasspathWatcher.kt | 4 ++-- .../kotlin/synthetic/SamAdapterFunctionsScope.kt | 2 +- .../jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt | 2 +- .../org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt | 6 +++--- .../kotlin/resolve/BindingContextUtils.kt | 2 +- .../org/jetbrains/kotlin/resolve/TypeResolver.kt | 4 ++-- .../kotlin/resolve/calls/util/callUtil.kt | 2 +- .../kotlin/resolve/scopes/utils/ScopeUtils.kt | 2 +- .../kotlin/codegen/TestStdlibWithDxTest.kt | 2 +- .../kotlin/jvm/compiler/AbstractSMAPBaseTest.kt | 2 +- .../descriptors/LazyJavaAnnotationDescriptor.kt | 2 +- .../lazy/descriptors/LazyJavaClassMemberScope.kt | 4 ++-- .../load/java/lazy/descriptors/MemberIndex.kt | 2 +- .../kotlin/load/kotlin/JvmNameResolver.kt | 2 +- .../load/kotlin/header/KotlinClassHeader.kt | 2 +- .../reflect/ReflectJavaClassifierType.kt | 2 +- .../kotlin/builtins/BuiltinsPackageFragment.kt | 2 +- .../jetbrains/kotlin/resolve/DescriptorUtils.kt | 2 +- .../org/jetbrains/kotlin/types/flexibleTypes.kt | 2 ++ .../deserialization/AnnotationDeserializer.kt | 2 +- .../descriptors/DeserializedClassDescriptor.kt | 2 +- .../org/jetbrains/kotlin/utils/collections.kt | 2 +- .../protobuf/GenerateProtoBufCompare.kt | 2 +- .../introduce/ExtractableSubstringInfo.kt | 2 +- .../org/jetbrains/kotlin/idea/util/FuzzyType.kt | 2 +- .../util/psi/patternMatching/KotlinPsiUnifier.kt | 2 +- .../decompiler/stubBuilder/TypeClsStubBuilder.kt | 2 +- .../decompiler/stubBuilder/clsStubBuilding.kt | 2 +- .../kotlin/idea/highlighter/IdeRenderers.kt | 4 ++-- .../idea/intentions/SelfTargetingIntention.kt | 2 +- .../jetbrains/kotlin/idea/util/CommentSaver.kt | 16 ++++++++-------- .../completion/KotlinCompletionContributor.kt | 2 +- .../src/org/jetbrains/kotlin/idea/core/Utils.kt | 2 +- .../codeInsight/KotlinExpressionTypeProvider.kt | 2 +- .../inspections/KotlinUnusedImportInspection.kt | 2 +- .../idea/quickfix/AddStarProjectionsFix.kt | 2 +- .../changeSignature/KotlinChangeInfo.kt | 6 +++--- .../KotlinChangeSignatureUsageProcessor.kt | 2 +- .../changeSignature/ui/KotlinCallerChooser.kt | 2 +- .../introduce/extractionEngine/extractorUtil.kt | 4 ++-- .../introduceVariable/introduceVariableUtils.kt | 2 +- .../idea/refactoring/jetRefactoringUtil.kt | 2 +- .../MoveKotlinDeclarationsProcessor.kt | 2 +- .../refactoring/pullUp/pullUpConflictsUtils.kt | 2 +- .../testIntegration/KotlinCreateTestIntention.kt | 2 +- .../kotlin/idea/util/ImportInsertHelperImpl.kt | 2 +- .../idea/codeInsight/AbstractInspectionTest.kt | 2 +- .../refactoring/AbstractMemberPullPushTest.kt | 2 +- .../refactoring/inline/AbstractInlineTest.kt | 2 +- .../introduce/AbstractExtractionTest.kt | 2 +- .../kotlin/j2k/JavaToKotlinConverter.kt | 2 +- .../jetbrains/kotlin/jps/build/KotlinBuilder.kt | 2 +- .../jps/incremental/JpsIncrementalCacheImpl.kt | 2 +- .../jps/build/AbstractLookupTrackerTest.kt | 2 +- .../classFilesComparison/classFilesComparison.kt | 4 +++- .../incremental/AbstractProtoComparisonTest.kt | 4 ++-- .../src/com/google/gwt/dev/js/ScopeContext.kt | 2 +- .../synthetic/AndroidComponentRegistrar.kt | 2 +- .../kotlin/annotation/StubProducerExtension.kt | 2 +- 68 files changed, 92 insertions(+), 86 deletions(-) diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ArgumentGenerator.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/ArgumentGenerator.kt index 24388fa15cf..8e69642331a 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ArgumentGenerator.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ArgumentGenerator.kt @@ -40,7 +40,7 @@ abstract class ArgumentGenerator { val actualArgsWithDeclIndex = actualArgs.filter { it !is DefaultValueArgument }.map { ArgumentAndDeclIndex(it, arg2Index[it]!!) - }.toArrayList() + }.toMutableList() valueArgumentsByIndex.withIndex().forEach { if (it.value is DefaultValueArgument) { diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/DefaultImplsClassContext.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/DefaultImplsClassContext.kt index 3a71a530f78..ad1a44235d7 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/context/DefaultImplsClassContext.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/context/DefaultImplsClassContext.kt @@ -38,7 +38,7 @@ class DefaultImplsClassContext( override fun getAccessors(): Collection> { val accessors = super.getAccessors() val alreadyExistKeys = accessors.map ({ Pair(it.calleeDescriptor, it.superCallTarget) }) - val filtered = interfaceContext.accessors.toMapBy({ Pair(it.calleeDescriptor, it.superCallTarget) }, { it }) - alreadyExistKeys + val filtered = interfaceContext.accessors.associateByTo(linkedMapOf()) { Pair(it.calleeDescriptor, it.superCallTarget) }.apply { keys -= alreadyExistKeys } return accessors + filtered.values } } \ No newline at end of file diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/PluginCliParser.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/PluginCliParser.kt index 953f11e22ad..345cd4ed1a7 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/PluginCliParser.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/PluginCliParser.kt @@ -38,7 +38,7 @@ object PluginCliParser { javaClass.classLoader ) - val componentRegistrars = ServiceLoader.load(ComponentRegistrar::class.java, classLoader).toArrayList() + val componentRegistrars = ServiceLoader.load(ComponentRegistrar::class.java, classLoader).toMutableList() componentRegistrars.addAll(BundledCompilerPlugins.componentRegistrars) configuration.addAll(ComponentRegistrar.PLUGIN_COMPONENT_REGISTRARS, componentRegistrars) @@ -55,11 +55,11 @@ object PluginCliParser { it.pluginId } ?: mapOf() - val commandLineProcessors = ServiceLoader.load(CommandLineProcessor::class.java, classLoader).toArrayList() + val commandLineProcessors = ServiceLoader.load(CommandLineProcessor::class.java, classLoader).toMutableList() commandLineProcessors.addAll(BundledCompilerPlugins.commandLineProcessors) for (processor in commandLineProcessors) { - val declaredOptions = processor.pluginOptions.toMapBy { it.name } + val declaredOptions = processor.pluginOptions.associateBy { it.name } val optionsToValues = MultiMap() for (optionValue in optionValuesByPlugin[processor.pluginId].orEmpty()) { diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Conditional.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Conditional.kt index e8d29863ef9..2969d9300e1 100644 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Conditional.kt +++ b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Conditional.kt @@ -47,7 +47,7 @@ interface Conditional { companion object { - val ANNOTATIONS: Map = listOf(JvmVersion, JsVersion, TargetName).toMapBy { it.name } + val ANNOTATIONS: Map = listOf(JvmVersion, JsVersion, TargetName).associateBy { it.name } } } diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Modifications.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Modifications.kt index 228fb457875..e426516be03 100644 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Modifications.kt +++ b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Modifications.kt @@ -25,7 +25,7 @@ data class Modification(val range: TextRange, val apply: (String) -> String) class CollectModificationsVisitor(evaluators: List) : KtTreeVisitorVoid() { val elementModifications: Map> = - evaluators.toMapBy(selector = { it }, transform = { arrayListOf() }) + evaluators.associateBy(keySelector = { it }, valueTransform = { arrayListOf() }) override fun visitDeclaration(declaration: KtDeclaration) { super.visitDeclaration(declaration) diff --git a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt index f64c10ff127..8ecde151efb 100644 --- a/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt +++ b/compiler/conditional-preprocessor/src/org.jetbrains.kotlin.preprocessor/Preprocessor.kt @@ -36,7 +36,7 @@ fun createJvmProfile(targetRoot: File, version: Int): Profile = Profile("JVM$ver fun createJsProfile(targetRoot: File): Profile = Profile("JS", JsPlatformEvaluator(), File(targetRoot, "js")) val profileEvaluators: Map Evaluator> = - listOf(6, 7, 8).toMapBy({ version -> "JVM$version" }, { version -> { JvmPlatformEvaluator(version) } }) + ("JS" to { JsPlatformEvaluator() }) + listOf(6, 7, 8).associateBy({ version -> "JVM$version" }, { version -> { JvmPlatformEvaluator(version) } }) + ("JS" to { JsPlatformEvaluator() }) fun createProfile(name: String, targetRoot: File): Profile { val (profileName, evaluator) = profileEvaluators.entries.firstOrNull { it.key.equals(name, ignoreCase = true) } ?: throw IllegalArgumentException("Profile with name '$name' is not supported") diff --git a/compiler/container/src/org/jetbrains/kotlin/container/Cache.kt b/compiler/container/src/org/jetbrains/kotlin/container/Cache.kt index 8300c8f378b..a634e9070c6 100644 --- a/compiler/container/src/org/jetbrains/kotlin/container/Cache.kt +++ b/compiler/container/src/org/jetbrains/kotlin/container/Cache.kt @@ -102,7 +102,7 @@ private fun collectInterfacesRecursive(type: Type, result: MutableSet) { private fun getRegistrations(klass: Class<*>): List { val registrations = ArrayList() - val superClasses = sequence(klass) { + val superClasses = generateSequence(klass) { when (it) { is Class<*> -> it.genericSuperclass is ParameterizedType -> (it.rawType as? Class<*>)?.genericSuperclass diff --git a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt index a3570880df3..7b0bc31ddeb 100644 --- a/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt +++ b/compiler/daemon/daemon-client/src/org/jetbrains/kotlin/daemon/client/KotlinCompilerClient.kt @@ -28,6 +28,7 @@ import java.io.PrintStream import java.rmi.server.UnicastRemoteObject import java.util.concurrent.Semaphore import java.util.concurrent.TimeUnit +import kotlin.comparisons.* import kotlin.concurrent.thread @@ -216,7 +217,7 @@ object KotlinCompilerClient { val memBefore = daemon.getUsedMemory().get() / 1024 val startTime = System.nanoTime() - val res = daemon.remoteCompile(CompileService.NO_SESSION, CompileService.TargetPlatform.JVM, filteredArgs.toArrayList().toTypedArray(), servicesFacade, outStrm, CompileService.OutputFormat.PLAIN, outStrm, null) + val res = daemon.remoteCompile(CompileService.NO_SESSION, CompileService.TargetPlatform.JVM, filteredArgs.toList().toTypedArray(), servicesFacade, outStrm, CompileService.OutputFormat.PLAIN, outStrm, null) val endTime = System.nanoTime() println("Compilation result code: $res") diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt index 4a1898f9ff7..f882ff752b7 100644 --- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt +++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/CompileServiceImpl.kt @@ -39,6 +39,7 @@ import java.util.concurrent.atomic.AtomicInteger import java.util.concurrent.locks.ReentrantReadWriteLock import java.util.logging.Level import java.util.logging.Logger +import kotlin.comparisons.* import kotlin.concurrent.read import kotlin.concurrent.schedule import kotlin.concurrent.write @@ -303,7 +304,7 @@ class CompileServiceImpl( synchronized(state.sessions) { // 2. check if any session hanged - clean // making copy of the list before calling release - state.sessions.filterValues { !it.isAlive }.keys.toArrayList() + state.sessions.filterValues { !it.isAlive }.keys.toList() }.forEach { releaseCompileSession(it) } // 3. check if in graceful shutdown state and all sessions are closed diff --git a/compiler/daemon/src/org/jetbrains/kotlin/daemon/LazyClasspathWatcher.kt b/compiler/daemon/src/org/jetbrains/kotlin/daemon/LazyClasspathWatcher.kt index bc9b9d2da6c..668e1aab81c 100644 --- a/compiler/daemon/src/org/jetbrains/kotlin/daemon/LazyClasspathWatcher.kt +++ b/compiler/daemon/src/org/jetbrains/kotlin/daemon/LazyClasspathWatcher.kt @@ -47,7 +47,7 @@ class LazyClasspathWatcher(classpath: Iterable, private data class FileId(val file: File, val lastModified: Long, val digest: ByteArray) private val fileIdsLock = Semaphore(1) // a barrier for ensuring ids are initialized, using semaphore to allow modifications from another thread - private var fileIds: ArrayList? = null + private var fileIds: List? = null private val lastChangedStatus = AtomicBoolean(false) private val lastUpdate = AtomicLong(0) private val lastDigestUpdate = AtomicLong(0) @@ -63,7 +63,7 @@ class LazyClasspathWatcher(classpath: Iterable, .asSequence() .flatMap { it.walk().filter(::isClasspathFile) } .map { FileId(it, it.lastModified(), it.md5Digest()) } - .toArrayList() + .toList() val nowMs = TimeUnit.MILLISECONDS.toMillis(System.nanoTime()) lastUpdate.set(nowMs) lastDigestUpdate.set(nowMs) diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt index 182a14d47be..6833167a0d4 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/SamAdapterFunctionsScope.kt @@ -108,7 +108,7 @@ class SamAdapterFunctionsScope(storageManager: StorageManager) : SyntheticScope sourceFunction.original.source) descriptor.sourceFunction = sourceFunction - val sourceTypeParams = (sourceFunction.typeParameters).toArrayList() + val sourceTypeParams = (sourceFunction.typeParameters).toMutableList() val ownerClass = sourceFunction.containingDeclaration as ClassDescriptor //TODO: should we go up parents for getters/setters too? //TODO: non-inner classes diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt index 7e73702490e..b8acee8d300 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/ktPsiUtil.kt @@ -69,7 +69,7 @@ fun KtSimpleNameExpression.getQualifiedElement(): KtElement { } fun KtSimpleNameExpression.getTopmostParentQualifiedExpressionForSelector(): KtQualifiedExpression? { - return sequence(this) { + return generateSequence(this) { val parentQualified = it.parent as? KtQualifiedExpression if (parentQualified?.selectorExpression == it) parentQualified else null }.last() as? KtQualifiedExpression diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt index 2883c9d7cd1..191aa09fcd9 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/psiUtil/psiUtils.kt @@ -60,7 +60,7 @@ fun PsiElement.siblings(forward: Boolean = true, withItself: Boolean = true): Se } val PsiElement.parentsWithSelf: Sequence - get() = sequence(this) { if (it is PsiFile) null else it.parent } + get() = generateSequence(this) { if (it is PsiFile) null else it.parent } val PsiElement.parents: Sequence get() = parentsWithSelf.drop(1) @@ -72,10 +72,10 @@ fun PsiElement.nextLeaf(skipEmptyElements: Boolean = false): PsiElement? = PsiTreeUtil.nextLeaf(this, skipEmptyElements) val PsiElement.prevLeafs: Sequence - get() = sequence({ prevLeaf() }, { it.prevLeaf() }) + get() = generateSequence({ prevLeaf() }, { it.prevLeaf() }) val PsiElement.nextLeafs: Sequence - get() = sequence({ nextLeaf() }, { it.nextLeaf() }) + get() = generateSequence({ nextLeaf() }, { it.nextLeaf() }) fun PsiElement.prevLeaf(filter: (PsiElement) -> Boolean): PsiElement? { var leaf = prevLeaf() diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContextUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContextUtils.kt index 5ad12af8c46..a738a199807 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContextUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContextUtils.kt @@ -45,7 +45,7 @@ fun KtReturnExpression.getTargetFunctionDescriptor(context: BindingContext): Fun val containingFunctionDescriptor = DescriptorUtils.getParentOfType(declarationDescriptor, FunctionDescriptor::class.java, false) if (containingFunctionDescriptor == null) return null - return sequence(containingFunctionDescriptor) { DescriptorUtils.getParentOfType(it, FunctionDescriptor::class.java) } + return generateSequence(containingFunctionDescriptor) { DescriptorUtils.getParentOfType(it, FunctionDescriptor::class.java) } .dropWhile { it is AnonymousFunctionDescriptor } .firstOrNull() } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index 7fe216ea22e..bf0c61240eb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -481,7 +481,7 @@ class TypeResolver( } private fun ClassifierDescriptor?.classDescriptorChain(): List - = sequence({ this as? ClassDescriptor }, { it.containingDeclaration as? ClassDescriptor }).toList() + = generateSequence({ this as? ClassDescriptor }, { it.containingDeclaration as? ClassDescriptor }).toList() private fun TypeParameterDescriptor.isDeclaredInScope(c: TypeResolutionContext): Boolean { assert(containingDeclaration is ClassDescriptor) { "This function is implemented for classes only, but $containingDeclaration was given" } @@ -499,7 +499,7 @@ class TypeResolver( } private fun DeclarationDescriptor.isInsideOfClass(classDescriptor: ClassDescriptor) - = sequence(this, { it.containingDeclaration }).any { it.original == classDescriptor } + = generateSequence(this, { it.containingDeclaration }).any { it.original == classDescriptor } private fun resolveTypeProjectionsWithErrorConstructor( diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt index d2863f10be3..f71c8812555 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/util/callUtil.kt @@ -105,7 +105,7 @@ fun Call.getValueArgumentForExpression(expression: KtExpression): ValueArgument? else -> null } } - fun KtElement.isParenthesizedExpression() = sequence(this) { it.deparenthesizeStructurally() }.any { it == expression } + fun KtElement.isParenthesizedExpression() = generateSequence(this) { it.deparenthesizeStructurally() }.any { it == expression } return valueArguments.firstOrNull { it?.getArgumentExpression()?.isParenthesizedExpression() ?: false } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt index 2c6b28d0101..255995a7028 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt @@ -27,7 +27,7 @@ import org.jetbrains.kotlin.util.collectionUtils.concat import org.jetbrains.kotlin.utils.Printer val HierarchicalScope.parentsWithSelf: Sequence - get() = sequence(this) { it.parent } + get() = generateSequence(this) { it.parent } val HierarchicalScope.parents: Sequence get() = parentsWithSelf.drop(1) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt index 47d1a401c07..a0728fccdc5 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/TestStdlibWithDxTest.kt @@ -34,7 +34,7 @@ class TestStdlibWithDxTest { private fun doTest(file: File) { val zip = ZipInputStream(FileInputStream(file)) zip.use { - sequence { zip.nextEntry }.forEach { + generateSequence { zip.nextEntry }.forEach { if (it.name.endsWith(".class")) { DxChecker.checkFileWithDx(zip.readBytes(), it.name) } diff --git a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractSMAPBaseTest.kt b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractSMAPBaseTest.kt index 04618e6e041..03dcf1ad823 100644 --- a/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractSMAPBaseTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/jvm/compiler/AbstractSMAPBaseTest.kt @@ -67,7 +67,7 @@ interface AbstractSMAPBaseTest { }.map { val smap = it.value.mapNotNull { it.smap?.replaceHash() }.joinToString("\n") SMAPAndFile(if (smap.isNotEmpty()) smap else null, it.key) - }.toMapBy { it.sourceFile } + }.associateBy { it.sourceFile } for (source in sourceData) { val data = compiledData[source.sourceFile] diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt index 79d6ffefc71..a675cda1392 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaAnnotationDescriptor.kt @@ -80,7 +80,7 @@ class LazyJavaAnnotationDescriptor( val constructors = getAnnotationClass().constructors if (constructors.isEmpty()) return mapOf() - val nameToArg = javaAnnotation.arguments.toMapBy { it.name } + val nameToArg = javaAnnotation.arguments.associateBy { it.name } return constructors.first().valueParameters.keysToMapExceptNulls { valueParameter -> var javaAnnotationArgument = nameToArg[valueParameter.getName()] diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt index d0322e1c75f..ea01b04b286 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/LazyJavaClassMemberScope.kt @@ -604,11 +604,11 @@ class LazyJavaClassMemberScope( } private val nestedClassIndex = c.storageManager.createLazyValue { - jClass.innerClasses.toMapBy { c -> c.name } + jClass.innerClasses.associateBy { c -> c.name } } private val enumEntryIndex = c.storageManager.createLazyValue { - jClass.fields.filter { it.isEnumEntry }.toMapBy { f -> f.name } + jClass.fields.filter { it.isEnumEntry }.associateBy { f -> f.name } } private val nestedClasses = c.storageManager.createMemoizedFunctionWithNullableValues { diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt index 2c8dac9490a..f3ae19014a6 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/java/lazy/descriptors/MemberIndex.kt @@ -58,7 +58,7 @@ open class ClassMemberIndex(val jClass: JavaClass, val memberFilter: (JavaMember } private val methods = jClass.methods.asSequence().filter(methodFilter).groupBy { m -> m.name } - private val fields = jClass.fields.asSequence().filter(memberFilter).toMapBy { m -> m.name } + private val fields = jClass.fields.asSequence().filter(memberFilter).associateBy { m -> m.name } override fun findMethodsByName(name: Name): Collection = methods[name] ?: listOf() override fun getMethodNames(nameFilter: (Name) -> Boolean): Collection = diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmNameResolver.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmNameResolver.kt index d945d759f17..22ce29dacde 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmNameResolver.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmNameResolver.kt @@ -131,7 +131,7 @@ class JvmNameResolver( "kotlin/collections/ListIterator", "kotlin/collections/MutableListIterator" ) - private val PREDEFINED_STRINGS_MAP = PREDEFINED_STRINGS.withIndex().toMapBy({ it.value }, { it.index }) + private val PREDEFINED_STRINGS_MAP = PREDEFINED_STRINGS.withIndex().associateBy({ it.value }, { it.index }) fun getPredefinedStringIndex(string: String): Int? = PREDEFINED_STRINGS_MAP[string] } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt index c905d7d9fa4..a5e68feddde 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/header/KotlinClassHeader.kt @@ -37,7 +37,7 @@ class KotlinClassHeader( MULTIFILE_CLASS_PART(5); companion object { - private val entryById = values().toMapBy(Kind::id) + private val entryById = values().associateBy(Kind::id) @JvmStatic fun getById(id: Int) = entryById[id] ?: UNKNOWN diff --git a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt index 93231e395d5..d917df10929 100644 --- a/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt +++ b/core/descriptors.runtime/src/org/jetbrains/kotlin/load/java/structure/reflect/ReflectJavaClassifierType.kt @@ -45,7 +45,7 @@ class ReflectJavaClassifierType(public override val type: Type) : ReflectJavaTyp override fun isRaw(): Boolean = with(type) { this is Class<*> && getTypeParameters().isNotEmpty() } override fun getTypeArguments(): List { - return sequence({type as? ParameterizedType}, { it.ownerType as? ParameterizedType }).flatMap { + return generateSequence({type as? ParameterizedType}, { it.ownerType as? ParameterizedType }).flatMap { it.actualTypeArguments.asSequence().map { ReflectJavaType.create(it) } }.toList() } diff --git a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt index d99361536b6..9da4a203f1c 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/builtins/BuiltinsPackageFragment.kt @@ -52,7 +52,7 @@ class BuiltinsPackageFragment( override val nameResolver = NameResolverImpl(builtinsMessage.strings, builtinsMessage.qualifiedNames) override val classIdToProto = - builtinsMessage.classList.toMapBy { klass -> + builtinsMessage.classList.associateBy { klass -> nameResolver.getClassId(klass.fqName) } diff --git a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt index 1a6e8b6e758..b2f60ee6d02 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/resolve/DescriptorUtils.kt @@ -192,7 +192,7 @@ fun Annotated.getAnnotationRetention(): KotlinRetention? { } val DeclarationDescriptor.parentsWithSelf: Sequence - get() = sequence(this, { it.containingDeclaration }) + get() = generateSequence(this, { it.containingDeclaration }) val DeclarationDescriptor.parents: Sequence get() = parentsWithSelf.drop(1) diff --git a/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt b/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt index 35ea21a598a..09b333c9901 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/types/flexibleTypes.kt @@ -127,6 +127,8 @@ open class DelegatingFlexibleType protected constructor( if (lowerBound == upperBound) return lowerBound return DelegatingFlexibleType(lowerBound, upperBound, extraCapabilities) } + + internal val ASSERTIONS_ENABLED = DelegatingFlexibleType::class.java.desiredAssertionStatus() } // These assertions are needed for checking invariants of flexible types. diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt index 3a9055de48e..3c31ee89ac7 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/AnnotationDeserializer.kt @@ -49,7 +49,7 @@ class AnnotationDeserializer(private val module: ModuleDescriptor) { if (proto.argumentCount != 0 && !ErrorUtils.isError(annotationClass) && DescriptorUtils.isAnnotationClass(annotationClass)) { val constructor = annotationClass.constructors.singleOrNull() if (constructor != null) { - val parameterByName = constructor.valueParameters.toMapBy { it.name } + val parameterByName = constructor.valueParameters.associateBy { it.name } arguments = proto.argumentList.map { resolveArgument(it, parameterByName, nameResolver) }.filterNotNull().toMap() } } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt index ed61a70737b..c63e926c3f8 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedClassDescriptor.kt @@ -287,7 +287,7 @@ class DeserializedClassDescriptor( } private inner class EnumEntryClassDescriptors { - private val enumEntryProtos = classProto.enumEntryList.toMapBy { c.nameResolver.getName(it.name) } + private val enumEntryProtos = classProto.enumEntryList.associateBy { c.nameResolver.getName(it.name) } private val protoContainer = ProtoContainer.Class(classProto, c.nameResolver, c.typeTable, (containingDeclaration as? ClassDescriptor)?.kind) diff --git a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt index 36f9235fac1..572be58990e 100644 --- a/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt +++ b/core/util.runtime/src/org/jetbrains/kotlin/utils/collections.kt @@ -19,7 +19,7 @@ package org.jetbrains.kotlin.utils import java.util.* fun Iterable.keysToMap(value: (K) -> V): Map { - return toMapBy({ it }, value) + return associateBy({ it }, value) } fun Iterable.keysToMapExceptNulls(value: (K) -> V?): Map { diff --git a/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt b/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt index b4c7b39b31a..6551db1e5e3 100644 --- a/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt +++ b/generators/src/org/jetbrains/kotlin/generators/protobuf/GenerateProtoBufCompare.kt @@ -63,7 +63,7 @@ class GenerateProtoBufCompare { private val extensionsMap = DebugJvmProtoBuf.getDescriptor().extensions.groupBy { it.containingType } private val allMessages: MutableSet = linkedSetOf() - private val messagesToProcess: Queue = linkedListOf() + private val messagesToProcess: Queue = LinkedList() private val repeatedFields: MutableSet = linkedSetOf() fun generate(): String { diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractableSubstringInfo.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractableSubstringInfo.kt index b8f6290fe58..0167ac84302 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractableSubstringInfo.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/refactoring/introduce/ExtractableSubstringInfo.kt @@ -73,7 +73,7 @@ class ExtractableSubstringInfo( get() = contentRange.shiftRight(-template.startOffset) val entries: Sequence - get() = sequence(startEntry) { if (it != endEntry) it.nextSiblingOfSameType() else null } + get() = generateSequence(startEntry) { if (it != endEntry) it.nextSiblingOfSameType() else null } fun createExpression(): KtExpression { val quote = template.firstChild.text diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt index 77e0244636d..0642b44d889 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/FuzzyType.kt @@ -142,7 +142,7 @@ class FuzzyType( if (otherSubstitutedType.isError) return null if (!substitutedType.checkInheritance(otherSubstitutedType)) return null - val substitution = constraintSystem.typeVariables.map { it.originalTypeParameter }.toMapBy({ it.typeConstructor }) { + val substitution = constraintSystem.typeVariables.map { it.originalTypeParameter }.associateBy({ it.typeConstructor }) { val type = it.defaultType val solution = substitutor.substitute(type, Variance.INVARIANT) TypeProjectionImpl(if (solution != null && !ErrorUtils.containsUninferredParameter(solution)) solution else type) diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt index 093d3fe4a75..8599a61980b 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/util/psi/patternMatching/KotlinPsiUnifier.kt @@ -883,7 +883,7 @@ class KotlinPsiUnifier( } } - private val descriptorToParameter = parameters.toMapBy { (it.descriptor as? DeclarationDescriptorWithSource)?.source?.getPsi() } + private val descriptorToParameter = parameters.associateBy { (it.descriptor as? DeclarationDescriptorWithSource)?.source?.getPsi() } private fun PsiElement.unwrap(): PsiElement? { return when (this) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt index 4164161b69f..c1c102ef10e 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/TypeClsStubBuilder.kt @@ -88,7 +88,7 @@ class TypeClsStubBuilder(private val c: ClsStubBuilderContext) { return } createTypeAnnotationStubs(parent, annotations) - val outerTypeChain = sequence(type) { it.outerType(c.typeTable) }.toList() + val outerTypeChain = generateSequence(type) { it.outerType(c.typeTable) }.toList() createStubForTypeName(classId, parent) { userTypeStub, index -> diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt index 482056d27e3..b3a01925669 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/decompiler/stubBuilder/clsStubBuilding.kt @@ -110,7 +110,7 @@ private fun setupFileStub(fileStub: KotlinFileStubImpl, packageFqName: FqName) { } fun createStubForPackageName(packageDirectiveStub: KotlinPlaceHolderStubImpl, packageFqName: FqName) { - val segments = packageFqName.pathSegments().toArrayList() + val segments = packageFqName.pathSegments() val iterator = segments.listIterator(segments.size) fun recCreateStubForPackageName(current: StubElement) { diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt index 8fb33f0a686..902aad800f0 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt @@ -26,6 +26,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData import org.jetbrains.kotlin.types.KotlinType +import kotlin.comparisons.* object IdeRenderers { @@ -43,8 +44,7 @@ object IdeRenderers { @JvmField val HTML_NONE_APPLICABLE_CALLS: Renderer>> = Renderer { calls: Collection> -> - // TODO: compareBy(comparator, selector) in stdlib - val comparator = comparator> { c1, c2 -> MemberComparator.INSTANCE.compare(c1.resultingDescriptor, c2.resultingDescriptor) } + val comparator = compareBy(MemberComparator.INSTANCE) { c: ResolvedCall<*> -> c.resultingDescriptor } calls .sortedWith(comparator) .joinToString("") { "
  • " + renderResolvedCall(it) + "
  • " } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt index fad662c3982..66ed1c20d23 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/intentions/SelfTargetingIntention.kt @@ -59,7 +59,7 @@ abstract class SelfTargetingIntention( val leaf2 = file.findElementAt(offset - 1) val commonParent = if (leaf1 != null && leaf2 != null) PsiTreeUtil.findCommonParent(leaf1, leaf2) else null - var elementsToCheck: Sequence = sequence { null } + var elementsToCheck: Sequence = emptySequence() if (leaf1 != null) { elementsToCheck += leaf1.parentsWithSelf.takeWhile { it != commonParent } } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt index 4a9edf7e18e..76a75d36119 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/CommentSaver.kt @@ -55,22 +55,22 @@ class CommentSaver(originalElements: PsiChildRange, private val saveLineBreaks: var lastChild: TreeElement? = null val children: Sequence - get() = sequence({ firstChild }, { it.next }) + get() = generateSequence({ firstChild }, { it.next }) val reverseChildren: Sequence - get() = sequence({ lastChild }, { it.prev }) + get() = generateSequence({ lastChild }, { it.prev }) val prevSiblings: Sequence - get() = sequence({ prev }, { it.prev }) + get() = generateSequence({ prev }, { it.prev }) val nextSiblings: Sequence - get() = sequence({ next }, { it.next }) + get() = generateSequence({ next }, { it.next }) val parents: Sequence - get() = sequence({ parent }, { it.parent }) + get() = generateSequence({ parent }, { it.parent }) val parentsWithSelf: Sequence - get() = sequence(this, { it.parent }) + get() = generateSequence(this, { it.parent }) val firstLeafInside: TreeElement get() { @@ -101,10 +101,10 @@ class CommentSaver(originalElements: PsiChildRange, private val saveLineBreaks: } val prevLeafs: Sequence - get() = sequence({ prevLeaf }, { it.prevLeaf }) + get() = generateSequence({ prevLeaf }, { it.prevLeaf }) val nextLeafs: Sequence - get() = sequence({ nextLeaf }, { it.nextLeaf }) + get() = generateSequence({ nextLeaf }, { it.nextLeaf }) fun withDescendants(leftToRight: Boolean): Sequence { val children = if (leftToRight) children else reverseChildren 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 8c9d41e0b95..806928bb3f4 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 @@ -462,7 +462,7 @@ class KotlinCompletionContributor : CompletionContributor() { private fun isInUnclosedSuperQualifier(tokenBefore: PsiElement?): Boolean { if (tokenBefore == null) return false val tokensToSkip = TokenSet.orSet(TokenSet.create(KtTokens.IDENTIFIER, KtTokens.DOT ), KtTokens.WHITE_SPACE_OR_COMMENT_BIT_SET) - val tokens = sequence(tokenBefore) { it.prevLeaf() } + val tokens = generateSequence(tokenBefore) { it.prevLeaf() } val ltToken = tokens.firstOrNull { it.node.elementType !in tokensToSkip } ?: return false if (ltToken.node.elementType != KtTokens.LT) return false val superToken = ltToken.prevLeaf { it !is PsiWhiteSpace && it !is PsiComment } diff --git a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt index 7bd566404bc..c0665c53f1d 100644 --- a/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt +++ b/idea/idea-core/src/org/jetbrains/kotlin/idea/core/Utils.kt @@ -52,7 +52,7 @@ fun Call.mapArgumentsToParameters(targetDescriptor: CallableDescriptor): Map() - val parametersByName = parameters.toMapBy { it.name } + val parametersByName = parameters.associateBy { it.name } var positionalArgumentIndex: Int? = 0 diff --git a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt index 80474ad9fc7..0e71147af43 100644 --- a/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt +++ b/idea/src/org/jetbrains/kotlin/idea/codeInsight/KotlinExpressionTypeProvider.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf class KotlinExpressionTypeProvider : ExpressionTypeProvider() { override fun getExpressionsAt(elementAt: PsiElement): List = - elementAt.parentsWithSelf.filterIsInstance().filterNot { it.shouldSkip() }.toArrayList() + elementAt.parentsWithSelf.filterIsInstance().filterNot { it.shouldSkip() }.toList() private fun KtExpression.shouldSkip(): Boolean { return this is KtStatementExpression && this !is KtFunction diff --git a/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinUnusedImportInspection.kt b/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinUnusedImportInspection.kt index bdace19b1d5..f995fda100d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinUnusedImportInspection.kt +++ b/idea/src/org/jetbrains/kotlin/idea/inspections/KotlinUnusedImportInspection.kt @@ -130,7 +130,7 @@ class KotlinUnusedImportInspection : AbstractKotlinInspection() { val optimizedImports = KotlinImportOptimizer.prepareOptimizedImports(file, descriptorsToImport) ?: return // return if already optimized // unwrap progress indicator - val progress = sequence(ProgressManager.getInstance().progressIndicator) { + val progress = generateSequence(ProgressManager.getInstance().progressIndicator) { (it as? ProgressWrapper)?.originalProgressIndicator }.last() as DaemonProgressIndicator val highlightingSession = HighlightingSessionImpl.getHighlightingSession(file, progress) diff --git a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddStarProjectionsFix.kt b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddStarProjectionsFix.kt index b1764960460..ab5b9647edb 100644 --- a/idea/src/org/jetbrains/kotlin/idea/quickfix/AddStarProjectionsFix.kt +++ b/idea/src/org/jetbrains/kotlin/idea/quickfix/AddStarProjectionsFix.kt @@ -44,7 +44,7 @@ open class AddStarProjectionsFix private constructor(element: KtUserType, public override fun createAction(diagnostic: Diagnostic): IntentionAction? { val diagnosticWithParameters = Errors.NO_TYPE_ARGUMENTS_ON_RHS.cast(diagnostic) val typeElement: KtTypeElement = diagnosticWithParameters.psiElement.typeElement ?: return null - val unwrappedType = sequence(typeElement) { (it as? KtNullableType)?.innerType }.lastOrNull() as? KtUserType ?: return null + val unwrappedType = generateSequence(typeElement) { (it as? KtNullableType)?.innerType }.lastOrNull() as? KtUserType ?: return null return AddStarProjectionsFix(unwrappedType, diagnosticWithParameters.a) } } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt index 39c67921439..d3a38d07e62 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeInfo.kt @@ -83,7 +83,7 @@ open class KotlinChangeInfo( field = value } - private val newParameters = parameterInfos.toArrayList() + private val newParameters = parameterInfos.toMutableList() private val originalPsiMethods = method.toLightMethods() private val originalParameters = (method as? KtFunction)?.valueParameters ?: emptyList() @@ -323,7 +323,7 @@ open class KotlinChangeInfo( val defaultValueCount = parameters.count { getDefaultValue(it) != null } if (psiMethods.size != defaultValueCount + 1) return emptyList() - val mandatoryParams = parameters.toArrayList() + val mandatoryParams = parameters.toMutableList() val defaultValues = ArrayList() return psiMethods.map { JvmOverloadSignature(it, mandatoryParams.map(getPsi).toSet(), defaultValues.toSet()).apply { @@ -360,7 +360,7 @@ open class KotlinChangeInfo( currentPsiMethods.singleOrNull()?.let { method -> return originalPsiMethods.keysToMap { method } } val currentSignatures = initCurrentSignatures(currentPsiMethods) - return originalSignatures.toMapBy({ it.method }) { originalSignature -> + return originalSignatures.associateBy({ it.method }) { originalSignature -> var constrainedCurrentSignatures = currentSignatures.map { it.constrainBy(originalSignature) } val maxMandatoryCount = constrainedCurrentSignatures.maxBy { it.mandatoryParams.size }!!.mandatoryParams.size constrainedCurrentSignatures = constrainedCurrentSignatures.filter { it.mandatoryParams.size == maxMandatoryCount } diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt index 35a5f3c6631..f447512fa30 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/KotlinChangeSignatureUsageProcessor.kt @@ -602,7 +602,7 @@ class KotlinChangeSignatureUsageProcessor : ChangeSignatureUsageProcessor { caller: KtNamedDeclaration, callerDescriptor: DeclarationDescriptor) { val valueParameters = caller.getValueParameters() - val existingParameters = valueParameters.toMapBy { it.name } + val existingParameters = valueParameters.associateBy { it.name } val signature = IdeDescriptorRenderers.SOURCE_CODE_SHORT_NAMES_IN_TYPES.render(callerDescriptor) for (parameterInfo in changeInfo.getNonReceiverParameters()) { if (!(parameterInfo.isNewParameter)) continue diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt index 800cbb4b8e4..49c82632fac 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/changeSignature/ui/KotlinCallerChooser.kt @@ -85,7 +85,7 @@ class KotlinMethodNode( is PsiMethod -> myMethod.getJavaMethodDescriptor() ?: return else -> throw AssertionError("Invalid declaration: ${myMethod.getElementTextWithContext()}") } - val containerName = sequence(descriptor) { it.containingDeclaration } + val containerName = generateSequence(descriptor) { it.containingDeclaration } .firstOrNull { it is ClassDescriptor } ?.name diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt index d78b057935a..c4a0ff52747 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/extractionEngine/extractorUtil.kt @@ -123,7 +123,7 @@ fun ExtractionGeneratorConfiguration.getDeclarationPattern( return buildSignature(this, descriptorRenderer).let { builder -> builder.transform { - for (i in sequence(indexOf('$')) { indexOf('$', it + 2) }) { + for (i in generateSequence(indexOf('$')) { indexOf('$', it + 2) }) { if (i < 0) break insert(i + 1, '$') } @@ -286,7 +286,7 @@ private fun makeCall( else -> calleeName } - val anchorInBlock = sequence(anchor) { it.parent }.firstOrNull { it.parent is KtBlockExpression } + val anchorInBlock = generateSequence(anchor) { it.parent }.firstOrNull { it.parent is KtBlockExpression } val block = (anchorInBlock?.parent as? KtBlockExpression) ?: anchorParent val psiFactory = KtPsiFactory(anchor.project) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/introduceVariableUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/introduceVariableUtils.kt index fca0f32d2af..a1c3e0ee2e8 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/introduceVariableUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/introduce/introduceVariable/introduceVariableUtils.kt @@ -64,7 +64,7 @@ private fun getApplicableComponentFunctions( val psiFactory = KtPsiFactory(contextExpression) @Suppress("UNCHECKED_CAST") - return sequence(1) { it + 1 } + return generateSequence(1) { it + 1 } .map { val componentCallExpr = psiFactory.createExpressionByPattern("$0.$1", receiverExpression ?: contextExpression, "component$it()") val newContext = componentCallExpr.analyzeInContext(scope, contextExpression) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt index 1fbf8ee30ca..1207e757624 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/jetRefactoringUtil.kt @@ -698,7 +698,7 @@ fun replaceListPsiAndKeepDelimiters( ): ListType { originalList.children.takeWhile { it is PsiErrorElement }.forEach { it.delete() } - val oldParameters = originalList.itemsFun().toArrayList() + val oldParameters = originalList.itemsFun().toMutableList() val newParameters = newList.itemsFun() val oldCount = oldParameters.size val newCount = newParameters.size diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveKotlinDeclarationsProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveKotlinDeclarationsProcessor.kt index 5d67d313e9a..9295e2861b6 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveKotlinDeclarationsProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/move/moveDeclarations/MoveKotlinDeclarationsProcessor.kt @@ -348,7 +348,7 @@ class MoveKotlinDeclarationsProcessor( } try { - val usageList = usages.toArrayList() + val usageList = usages.toList() descriptor.delegate.preprocessUsages(project, usageList) diff --git a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/pullUpConflictsUtils.kt b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/pullUpConflictsUtils.kt index 94cdc43df72..7bbd746b436 100644 --- a/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/pullUpConflictsUtils.kt +++ b/idea/src/org/jetbrains/kotlin/idea/refactoring/pullUp/pullUpConflictsUtils.kt @@ -160,7 +160,7 @@ private fun KotlinPullUpData.checkVisibility( } val member = memberInfo.member - val childrenToCheck = member.allChildren.toArrayList() + val childrenToCheck = member.allChildren.toMutableList() if (memberInfo.isToAbstract && member is KtCallableDeclaration) { when (member) { is KtNamedFunction -> childrenToCheck.remove(member.bodyExpression as PsiElement?) diff --git a/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt b/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt index 8e09d00b75b..1e4f1d4ad95 100644 --- a/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/testIntegration/KotlinCreateTestIntention.kt @@ -103,7 +103,7 @@ class KotlinCreateTestIntention : SelfTargetingRangeIntention): Set { if (importedClasses.isEmpty()) return setOf() - val classesToCheck = importedClasses.map { it.name to it }.toMap().toLinkedMap() + val classesToCheck = importedClasses.associateByTo(mutableMapOf()) { it.name } val result = LinkedHashSet() file.accept(object : KtVisitorVoid() { override fun visitElement(element: PsiElement) { diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt index cf31cd857a5..e99d625c39e 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/AbstractInspectionTest.kt @@ -77,7 +77,7 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase() null } else if (file.extension != "kt") { - val filePath = file.relativeToFile(srcDir).invariantSeparatorsPath + val filePath = file.relativeTo(srcDir).invariantSeparatorsPath configureByFile(filePath) } else { diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMemberPullPushTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMemberPullPushTest.kt index 94bfcc0cea6..7fd37ca62ba 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMemberPullPushTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/AbstractMemberPullPushTest.kt @@ -61,7 +61,7 @@ abstract class AbstractMemberPullPushTest : KotlinLightCodeInsightFixtureTestCas val extraFiles = mainFile.parentFile.listFiles { file, name -> name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java")) } - val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(it.name) } + val extraFilesToPsi = extraFiles.associateBy { fixture.configureByFile(it.name) } val file = fixture.configureByFile(mainFileName) val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// WITH_RUNTIME") != null diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/inline/AbstractInlineTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/inline/AbstractInlineTest.kt index 301a0afa371..70d5b6517c0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/inline/AbstractInlineTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/inline/AbstractInlineTest.kt @@ -44,7 +44,7 @@ abstract class AbstractInlineTest : KotlinLightCodeInsightFixtureTestCase() { val extraFiles = mainFile.parentFile.listFiles { file, name -> name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java")) } - val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(path.replace(mainFileName, it.name)) } + val extraFilesToPsi = extraFiles.associateBy { fixture.configureByFile(path.replace(mainFileName, it.name)) } val file = myFixture.configureByFile(path) val afterFileExists = afterFile.exists() diff --git a/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractExtractionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractExtractionTest.kt index da36c6db66d..ec8b8ec83b0 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractExtractionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/refactoring/introduce/AbstractExtractionTest.kt @@ -319,7 +319,7 @@ abstract class AbstractExtractionTest() : KotlinLightCodeInsightFixtureTestCase( val extraFiles = mainFile.parentFile.listFiles { file, name -> name != mainFileName && name.startsWith("$mainFileBaseName.") && (name.endsWith(".kt") || name.endsWith(".java")) } - val extraFilesToPsi = extraFiles.toMapBy { fixture.configureByFile(it.name) } + val extraFilesToPsi = extraFiles.associateBy { fixture.configureByFile(it.name) } val file = fixture.configureByFile(mainFileName) val addKotlinRuntime = InTextDirectivesUtils.findStringWithPrefixes(file.text, "// WITH_RUNTIME") != null diff --git a/j2k/src/org/jetbrains/kotlin/j2k/JavaToKotlinConverter.kt b/j2k/src/org/jetbrains/kotlin/j2k/JavaToKotlinConverter.kt index 408faea624e..4669adbef15 100644 --- a/j2k/src/org/jetbrains/kotlin/j2k/JavaToKotlinConverter.kt +++ b/j2k/src/org/jetbrains/kotlin/j2k/JavaToKotlinConverter.kt @@ -107,7 +107,7 @@ class JavaToKotlinConverter( val intermediateResults = processor.processItems(0.25, inputElements) { inputElement -> Converter.create(inputElement, settings, services, ::inConversionScope, usageProcessingCollector).convert() - }.toArrayList() + }.toMutableList() val results = processor.processItems(0.25, intermediateResults.withIndex()) { pair -> val (i, result) = pair diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt index 2a27f056ffe..34464c46c5c 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/build/KotlinBuilder.kt @@ -830,7 +830,7 @@ private fun withSubtypes( typeFqName: FqName, caches: Sequence> ): Set { - val types = linkedListOf(typeFqName) + val types = LinkedList(listOf(typeFqName)) val subtypes = hashSetOf() while (types.isNotEmpty()) { diff --git a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsIncrementalCacheImpl.kt b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsIncrementalCacheImpl.kt index 2a65d8916df..8c199778276 100644 --- a/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsIncrementalCacheImpl.kt +++ b/jps-plugin/src/org/jetbrains/kotlin/jps/incremental/JpsIncrementalCacheImpl.kt @@ -81,7 +81,7 @@ class JpsIncrementalCacheImpl( private inner class DirtyInlineFunctionsMap(storageFile: File) : BasicStringMap>(storageFile, StringCollectionExternalizer) { fun getEntries(): Map> = - storage.keys.toMapBy(JvmClassName::byInternalName) { storage[it]!! } + storage.keys.associateBy(JvmClassName::byInternalName) { storage[it]!! } fun put(className: JvmClassName, changedFunctions: List) { storage[className.internalName] = changedFunctions diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt index bf79ec43766..e711b055b75 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/AbstractLookupTrackerTest.kt @@ -53,7 +53,7 @@ abstract class AbstractLookupTrackerTest : AbstractIncrementalJpsTest( fail("File $actualFile unexpectedly contains multiline comments. In range ${matchResult.range} found: ${matchResult.value} in $text") } - val lines = text.lines().toArrayList() + val lines = text.lines().toMutableList() for ((line, lookupsFromLine) in lookupsFromFile.groupBy { it.position.line }) { val columnToLookups = lookupsFromLine.groupBy { it.position.column }.toList().sortedBy { it.first } diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/build/classFilesComparison/classFilesComparison.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/build/classFilesComparison/classFilesComparison.kt index e2fdf2ca5f5..64f7260b6f5 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/build/classFilesComparison/classFilesComparison.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/build/classFilesComparison/classFilesComparison.kt @@ -36,6 +36,8 @@ import java.io.File import java.io.PrintWriter import java.io.StringWriter import java.util.* +import kotlin.comparisons.* + // Set this to true if you want to dump all bytecode (test will fail in this case) val DUMP_ALL = System.getProperty("comparison.dump.all") == "true" @@ -53,7 +55,7 @@ fun getDirectoryString(dir: File, interestingPaths: List): String { val listFiles = dir.listFiles() assertNotNull(listFiles) - val children = listFiles!!.sortedWith(compareBy ({ it.isDirectory }, { it.name } )) + val children = listFiles!!.sortedWith(compareBy({ it.isDirectory }, { it.name })) for (child in children) { if (child.isDirectory) { p.println(child.name) diff --git a/jps-plugin/test/org/jetbrains/kotlin/jps/incremental/AbstractProtoComparisonTest.kt b/jps-plugin/test/org/jetbrains/kotlin/jps/incremental/AbstractProtoComparisonTest.kt index 922bad39daf..9cf233a9f79 100644 --- a/jps-plugin/test/org/jetbrains/kotlin/jps/incremental/AbstractProtoComparisonTest.kt +++ b/jps-plugin/test/org/jetbrains/kotlin/jps/incremental/AbstractProtoComparisonTest.kt @@ -37,8 +37,8 @@ abstract class AbstractProtoComparisonTest : UsefulTestCase() { val oldClassFiles = compileFileAndGetClasses(testDataPath, testDir, "old") val newClassFiles = compileFileAndGetClasses(testDataPath, testDir, "new") - val oldClassMap = oldClassFiles.toMapBy { it.name } - val newClassMap = newClassFiles.toMapBy { it.name } + val oldClassMap = oldClassFiles.associateBy { it.name } + val newClassMap = newClassFiles.associateBy { it.name } val sb = StringBuilder() val p = Printer(sb) diff --git a/js/js.parser/src/com/google/gwt/dev/js/ScopeContext.kt b/js/js.parser/src/com/google/gwt/dev/js/ScopeContext.kt index 3cb3cb67aff..6c0cf58a436 100644 --- a/js/js.parser/src/com/google/gwt/dev/js/ScopeContext.kt +++ b/js/js.parser/src/com/google/gwt/dev/js/ScopeContext.kt @@ -21,7 +21,7 @@ import com.google.dart.compiler.backend.js.ast.* import java.util.Stack class ScopeContext(scope: JsScope) { - private val rootScope = sequence(scope) { it.parent }.first { it is JsRootScope } + private val rootScope = generateSequence(scope) { it.parent }.first { it is JsRootScope } private val scopes = Stack(); init { diff --git a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt index d0e8217a239..320236228a1 100644 --- a/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt +++ b/plugins/android-compiler-plugin/src/org/jetbrains/kotlin/android/synthetic/AndroidComponentRegistrar.kt @@ -59,7 +59,7 @@ class AndroidCommandLineProcessor : CommandLineProcessor { override fun processOption(option: CliOption, value: String, configuration: CompilerConfiguration) { when (option) { VARIANT_OPTION -> { - val paths = configuration.getList(AndroidConfigurationKeys.VARIANT).toArrayList() + val paths = configuration.getList(AndroidConfigurationKeys.VARIANT).toMutableList() paths.add(value) configuration.put(AndroidConfigurationKeys.VARIANT, paths) } diff --git a/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/StubProducerExtension.kt b/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/StubProducerExtension.kt index ddfe5e87f80..7d01f0516c6 100644 --- a/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/StubProducerExtension.kt +++ b/plugins/annotation-collector/src/org/jetbrains/kotlin/annotation/StubProducerExtension.kt @@ -43,7 +43,7 @@ class StubProducerExtension(val stubsOutputDir: File) : AnalysisCompletedHandler StubClassBuilderFactory(), module, bindingContext, - files.toArrayList(), + files.toList(), disableCallAssertions = false, disableParamAssertions = false)