Minor: use List instead of Array as container in chained scopes

This commit is contained in:
Zalim Bashorov
2015-12-15 18:41:04 +03:00
parent 5008a66a5b
commit 976fbf32ba
12 changed files with 36 additions and 35 deletions
@@ -130,7 +130,7 @@ public class IncrementalPackageFragmentProvider(
MemberScope.Empty
}
else {
ChainedMemberScope("Member scope for incremental compilation: union of package parts data", *scopes.toTypedArray())
ChainedMemberScope("Member scope for incremental compilation: union of package parts data", scopes)
}
}
}
@@ -155,7 +155,7 @@ public class IncrementalPackageFragmentProvider(
val scopes = partsData.map { IncrementalPackageScope(JvmProtoBufUtil.readPackageDataFrom(it.data, it.strings)) }
ChainedMemberScope(
"Member scope for incremental compilation: union of multifile class parts data for $multifileClassFqName",
*scopes.toTypedArray<MemberScope>())
scopes)
}
}
@@ -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}"
@@ -194,7 +194,10 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
private val scope: MemberScope
init {
scope = ChainedMemberScope("synthetic package view for test", ScopeWithClassifiers(classes), *packageScopes.toTypedArray())
val list = ArrayList<MemberScope>(packageScopes.size + 1)
list.add(ScopeWithClassifiers(classes))
list.addAll(packageScopes)
scope = ChainedMemberScope("synthetic package view for test", list)
}
override val fqName: FqName
@@ -54,6 +54,7 @@ import org.jetbrains.kotlin.tests.di.InjectionKt;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
@@ -104,10 +105,10 @@ public class TypeSubstitutorTest extends KotlinTestWithEnvironment {
}
});
return new LexicalChainedScope(typeParameters, module, false, null, LexicalScopeKind.SYNTHETIC,
new MemberScope[] {
contextClass.getDefaultType().getMemberScope(),
module.getBuiltIns().getBuiltInsPackageScope()
});
Arrays.asList(
contextClass.getDefaultType().getMemberScope(),
module.getBuiltIns().getBuiltInsPackageScope()
));
}
private void doTest(@Nullable String expectedTypeStr, String initialTypeStr, Pair<String, String>... substitutionStrs) {