Replace function MemberScope.getContainingDeclaration() to property ownerDescriptor

This commit is contained in:
Stanislav Erokhin
2015-11-04 15:29:33 +03:00
parent 52dc23012f
commit c4582d0e0c
32 changed files with 86 additions and 90 deletions
@@ -62,7 +62,7 @@ class LazyOperationsLog(
public fun getText(): String {
val groupedByOwner = records.groupByTo(IdentityHashMap()) {
val owner = it.data.fieldOwner
if (owner is MemberScope) owner.getContainingDeclaration() else owner
if (owner is MemberScope) owner.ownerDescriptor else owner
}.map { Pair(it.getKey(), it.getValue()) }
return groupedByOwner.map {
@@ -40,14 +40,14 @@ private fun validateDeserializedScope(scope: MemberScope) {
val relevantDescriptors = scope.getContributedDescriptors().filter { member ->
member is CallableMemberDescriptor && member.getKind().isReal() || (!isPackageViewScope && member is ClassDescriptor)
}
checkSorted(relevantDescriptors, scope.getContainingDeclaration())
checkSorted(relevantDescriptors, scope.ownerDescriptor)
}
}
//NOTE: see TypeUtils#IntersectionScope#getContainingDeclaration()
private fun MemberScope.safeGetContainingDeclaration(): DeclarationDescriptor? {
return try {
getContainingDeclaration()
ownerDescriptor
}
catch (e: UnsupportedOperationException) {
null
@@ -213,10 +213,8 @@ public abstract class AbstractJvmRuntimeDescriptorLoaderTest : TestCaseWithTmpdi
private class ScopeWithClassifiers(
classifiers: List<ClassifierDescriptor>,
val ownerDescriptor: DeclarationDescriptor
override val ownerDescriptor: DeclarationDescriptor
) : MemberScopeImpl() {
override fun getContainingDeclaration() = ownerDescriptor
private val classifierMap = HashMap<Name, ClassifierDescriptor>()
val redeclarationHandler = RedeclarationHandler.THROW_EXCEPTION
@@ -200,7 +200,7 @@ public class TypeUnifierTest extends KotlinLiteFixture {
}
private TypeProjection makeTypeProjection(MemberScope scope, String typeStr) {
LexicalScope withX = new LexicalScopeImpl(TypeTestUtilsKt.asLexicalScope(scope), scope.getContainingDeclaration(),
LexicalScope withX = new LexicalScopeImpl(TypeTestUtilsKt.asLexicalScope(scope), scope.getOwnerDescriptor(),
false, null, "With X", RedeclarationHandler.DO_NOTHING,
new Function1<LexicalScopeImpl.InitializeHandler, Unit>() {
@Override
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.utils.Printer
public fun MemberScope.asLexicalScope(): LexicalScope {
val importingScope = memberScopeAsImportingScope()
return object : BaseLexicalScope(importingScope, getContainingDeclaration()) {
return object : BaseLexicalScope(importingScope, ownerDescriptor) {
override fun printStructure(p: Printer) {
p.println("Util scope for tests")
}