Minor: use List instead of Array as container in chained scopes
This commit is contained in:
+1
-1
@@ -141,7 +141,7 @@ class ClassResolutionScopesSupport(
|
||||
return LexicalChainedScope(parentForNewScope, ownerDescriptor, false,
|
||||
implicitReceiver,
|
||||
LexicalScopeKind.CLASS_INHERITANCE,
|
||||
memberScopes = *staticScopes.toTypedArray(), isStaticScope = true)
|
||||
memberScopes = staticScopes, isStaticScope = true)
|
||||
}
|
||||
|
||||
private fun <T : Any> StorageManager.createLazyValue(onRecursion: ((Boolean) -> T), compute: () -> T) =
|
||||
|
||||
@@ -31,21 +31,20 @@ public class LexicalChainedScope @JvmOverloads constructor(
|
||||
override val isOwnerDescriptorAccessibleByLabel: Boolean,
|
||||
override val implicitReceiver: ReceiverParameterDescriptor?,
|
||||
override val kind: LexicalScopeKind,
|
||||
vararg memberScopes: MemberScope,
|
||||
private val memberScopes: List<MemberScope>,
|
||||
@Deprecated("This value is temporary hack for resolve -- don't use it!")
|
||||
val isStaticScope: Boolean = false
|
||||
): LexicalScope {
|
||||
override val parent = parent.takeSnapshot()
|
||||
private val scopeChain = memberScopes.clone()
|
||||
|
||||
override fun getContributedDescriptors(kindFilter: DescriptorKindFilter, nameFilter: (Name) -> Boolean)
|
||||
= getFromAllScopes(scopeChain) { it.getContributedDescriptors() }
|
||||
= getFromAllScopes(memberScopes) { it.getContributedDescriptors() }
|
||||
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(scopeChain) { it.getContributedClassifier(name, location) }
|
||||
override fun getContributedClassifier(name: Name, location: LookupLocation) = getFirstMatch(memberScopes) { it.getContributedClassifier(name, location) }
|
||||
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getContributedVariables(name, location) }
|
||||
override fun getContributedVariables(name: Name, location: LookupLocation) = getFromAllScopes(memberScopes) { it.getContributedVariables(name, location) }
|
||||
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFromAllScopes(scopeChain) { it.getContributedFunctions(name, location) }
|
||||
override fun getContributedFunctions(name: Name, location: LookupLocation) = getFromAllScopes(memberScopes) { it.getContributedFunctions(name, location) }
|
||||
|
||||
override fun toString(): String = kind.toString()
|
||||
|
||||
@@ -54,7 +53,7 @@ public class LexicalChainedScope @JvmOverloads constructor(
|
||||
" with implicitReceiver: ", implicitReceiver?.value ?: "NONE", " {")
|
||||
p.pushIndent()
|
||||
|
||||
for (scope in scopeChain) {
|
||||
for (scope in memberScopes) {
|
||||
scope.printScopeStructure(p)
|
||||
}
|
||||
|
||||
@@ -65,4 +64,4 @@ public class LexicalChainedScope @JvmOverloads constructor(
|
||||
p.println("}")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,8 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.classValueType
|
||||
import org.jetbrains.kotlin.resolve.scopes.ChainedMemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.FilteringScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.ScopeUtils
|
||||
import org.jetbrains.kotlin.resolve.scopes.MemberScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.ScopeUtils
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import java.util.*
|
||||
|
||||
@@ -112,7 +112,7 @@ class ClassQualifier(
|
||||
scopes.add(classifier.unsubstitutedInnerClassesScope)
|
||||
}
|
||||
|
||||
return ChainedMemberScope("Member scope for $name as class or object", *scopes.toTypedArray())
|
||||
return ChainedMemberScope("Member scope for $name as class or object", scopes)
|
||||
}
|
||||
|
||||
override fun getNestedClassesAndPackageMembersScope(): MemberScope {
|
||||
@@ -128,7 +128,7 @@ class ClassQualifier(
|
||||
scopes.add(ScopeUtils.getStaticNestedClassesScope(classifier))
|
||||
}
|
||||
|
||||
return ChainedMemberScope("Static scope for $name as class or object", *scopes.toTypedArray())
|
||||
return ChainedMemberScope("Static scope for $name as class or object", scopes)
|
||||
}
|
||||
|
||||
override fun toString() = "Class{$classifier}"
|
||||
|
||||
Reference in New Issue
Block a user