Dropped one usage of asKtScope()
This commit is contained in:
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.renderer.render
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.ImportPath
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.getImportableDescriptor
|
||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.*
|
||||
import java.util.*
|
||||
|
||||
@@ -118,26 +118,28 @@ public class KotlinImportOptimizer() : ImportOptimizer {
|
||||
private fun isAccessibleAsMember(target: DeclarationDescriptor, place: KtElement, bindingContext: BindingContext): Boolean {
|
||||
if (target.containingDeclaration !is ClassDescriptor) return false
|
||||
|
||||
fun isInScope(scope: KtScope): Boolean {
|
||||
return when (target) {
|
||||
is FunctionDescriptor ->
|
||||
scope.getFunctions(target.name, NoLookupLocation.FROM_IDE).contains(target)
|
||||
fun isInScope(scope: LexicalScope): Boolean {
|
||||
return scope.parentsWithSelf.any {
|
||||
when (target) {
|
||||
is FunctionDescriptor ->
|
||||
it.getDeclaredFunctions(target.name, NoLookupLocation.FROM_IDE).contains(target)
|
||||
|
||||
is PropertyDescriptor ->
|
||||
scope.getProperties(target.name, NoLookupLocation.FROM_IDE).contains(target)
|
||||
is PropertyDescriptor ->
|
||||
it.getDeclaredVariables(target.name, NoLookupLocation.FROM_IDE).contains(target)
|
||||
|
||||
is ClassDescriptor ->
|
||||
scope.getClassifier(target.name, NoLookupLocation.FROM_IDE) == target
|
||||
is ClassDescriptor ->
|
||||
it.getDeclaredClassifier(target.name, NoLookupLocation.FROM_IDE) == target
|
||||
|
||||
else -> false
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val resolutionScope = place.getResolutionScope(bindingContext, place.getResolutionFacade())
|
||||
val noImportsScope = resolutionScope.replaceImportingScopes(null)
|
||||
|
||||
return isInScope(noImportsScope.asKtScope())
|
||||
|| resolutionScope.getImplicitReceiversHierarchy().any { isInScope(it.type.memberScope) }
|
||||
return isInScope(noImportsScope)
|
||||
|| resolutionScope.getImplicitReceiversHierarchy().any { isInScope(it.type.memberScope.memberScopeAsImportingScope()) }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user