From 6d90a7a8d9fb1c1ee57b875771450857c8672691 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 30 Oct 2014 19:15:13 +0300 Subject: [PATCH] Minor code simplifications --- .../jet/lang/resolve/scopes/ChainedScope.kt | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/scopes/ChainedScope.kt b/core/descriptors/src/org/jetbrains/jet/lang/resolve/scopes/ChainedScope.kt index ae6f36853d5..93833da9a0c 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/scopes/ChainedScope.kt +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/scopes/ChainedScope.kt @@ -48,9 +48,7 @@ public class ChainedScope(private val containingDeclaration: DeclarationDescript override fun getImplicitReceiversHierarchy(): List { if (implicitReceiverHierarchy == null) { val result = ArrayList() - for (jetScope in scopeChain) { - result.addAll(jetScope.getImplicitReceiversHierarchy()) - } + scopeChain.flatMapTo(result) { it.getImplicitReceiversHierarchy() } result.trimToSize() implicitReceiverHierarchy = result } @@ -59,14 +57,7 @@ public class ChainedScope(private val containingDeclaration: DeclarationDescript override fun getContainingDeclaration(): DeclarationDescriptor = containingDeclaration!! - override fun getDeclarationsByLabel(labelName: Name): Collection { - val result = ArrayList() - for (jetScope in scopeChain) { - result.addAll(jetScope.getDeclarationsByLabel(labelName)) - } - result.trimToSize() - return result - } + override fun getDeclarationsByLabel(labelName: Name) = scopeChain.flatMap { it.getDeclarationsByLabel(labelName) } override fun getDescriptors(kindFilter: (JetScope.DescriptorKind) -> Boolean, nameFilter: (String) -> Boolean): Collection {