Allow to use static members from companion object's parents

This commit is contained in:
Zalim Bashorov
2015-12-14 20:58:36 +03:00
parent 69c2668530
commit 51a8d5b9f0
12 changed files with 439 additions and 1 deletions
@@ -123,15 +123,24 @@ class ClassResolutionScopesSupport(
val implicitReceiver: ReceiverParameterDescriptor?
val parentForNewScope: LexicalScope
if (withCompanionObject) {
staticScopes.addIfNotNull(classDescriptor.companionObjectDescriptor?.unsubstitutedInnerClassesScope)
implicitReceiver = classDescriptor.companionObjectDescriptor?.thisAsReceiverParameter
parentForNewScope = classDescriptor.companionObjectDescriptor?.let {
it.getAllSuperclassesWithoutAny().asReversed().fold(parent) { scope, currentClass ->
createInheritanceScope(parent = scope, ownerDescriptor = ownerDescriptor, classDescriptor = currentClass, withCompanionObject = false)
}
} ?: parent
}
else {
implicitReceiver = null
parentForNewScope = parent
}
return LexicalChainedScope(parent, ownerDescriptor, false,
return LexicalChainedScope(parentForNewScope, ownerDescriptor, false,
implicitReceiver,
LexicalScopeKind.CLASS_INHERITANCE,
memberScopes = *staticScopes.toTypedArray(), isStaticScope = true)