Removed more usages of asKtScope()
This commit is contained in:
+10
-14
@@ -66,7 +66,8 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.scopes.*
|
import org.jetbrains.kotlin.resolve.scopes.*
|
||||||
import org.jetbrains.kotlin.resolve.scopes.utils.asKtScope
|
import org.jetbrains.kotlin.resolve.scopes.utils.getClassifier
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
|
||||||
import org.jetbrains.kotlin.types.KotlinType
|
import org.jetbrains.kotlin.types.KotlinType
|
||||||
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
import org.jetbrains.kotlin.types.TypeProjectionImpl
|
||||||
import org.jetbrains.kotlin.types.Variance
|
import org.jetbrains.kotlin.types.Variance
|
||||||
@@ -84,7 +85,7 @@ private val ATTRIBUTE_FUNCTION_NAME = "FUNCTION_NAME"
|
|||||||
/**
|
/**
|
||||||
* Represents a single choice for a type (e.g. parameter type or return type).
|
* Represents a single choice for a type (e.g. parameter type or return type).
|
||||||
*/
|
*/
|
||||||
class TypeCandidate(val theType: KotlinType, scope: KtScope? = null) {
|
class TypeCandidate(val theType: KotlinType, scope: LexicalScope? = null) {
|
||||||
public val typeParameters: Array<TypeParameterDescriptor>
|
public val typeParameters: Array<TypeParameterDescriptor>
|
||||||
var renderedType: String? = null
|
var renderedType: String? = null
|
||||||
private set
|
private set
|
||||||
@@ -161,7 +162,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
fun computeTypeCandidates(
|
fun computeTypeCandidates(
|
||||||
typeInfo: TypeInfo,
|
typeInfo: TypeInfo,
|
||||||
substitutions: List<JetTypeSubstitution>,
|
substitutions: List<JetTypeSubstitution>,
|
||||||
scope: KtScope): List<TypeCandidate> {
|
scope: LexicalScope): List<TypeCandidate> {
|
||||||
if (!typeInfo.substitutionsAllowed) return computeTypeCandidates(typeInfo)
|
if (!typeInfo.substitutionsAllowed) return computeTypeCandidates(typeInfo)
|
||||||
return typeCandidates.getOrPut(typeInfo) {
|
return typeCandidates.getOrPut(typeInfo) {
|
||||||
val types = typeInfo.getPossibleTypes(this).asReversed()
|
val types = typeInfo.getPossibleTypes(this).asReversed()
|
||||||
@@ -336,13 +337,13 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
mandatoryTypeParametersAsCandidates.forEach { it.render(typeParameterNameMap, fakeFunction) }
|
mandatoryTypeParametersAsCandidates.forEach { it.render(typeParameterNameMap, fakeFunction) }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getDeclarationScope(): KtScope {
|
private fun getDeclarationScope(): LexicalScope {
|
||||||
if (config.isExtension || receiverClassDescriptor == null) {
|
if (config.isExtension || receiverClassDescriptor == null) {
|
||||||
return currentFileModule.getPackage(config.currentFile.getPackageFqName()).memberScope
|
return currentFileModule.getPackage(config.currentFile.packageFqName).memberScope.memberScopeAsImportingScope()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (receiverClassDescriptor is ClassDescriptorWithResolutionScopes) {
|
if (receiverClassDescriptor is ClassDescriptorWithResolutionScopes) {
|
||||||
return receiverClassDescriptor.getScopeForMemberDeclarationResolution().asKtScope()
|
return receiverClassDescriptor.scopeForMemberDeclarationResolution
|
||||||
}
|
}
|
||||||
|
|
||||||
assert (receiverClassDescriptor is JavaClassDescriptor) { "Unexpected receiver class: $receiverClassDescriptor" }
|
assert (receiverClassDescriptor is JavaClassDescriptor) { "Unexpected receiver class: $receiverClassDescriptor" }
|
||||||
@@ -364,12 +365,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
.map { TypeProjectionImpl(it.getDefaultType()) }
|
.map { TypeProjectionImpl(it.getDefaultType()) }
|
||||||
val memberScope = receiverClassDescriptor.getMemberScope(projections)
|
val memberScope = receiverClassDescriptor.getMemberScope(projections)
|
||||||
|
|
||||||
return ChainedScope(
|
return typeParamScope.memberScopeAsImportingScope(memberScope.memberScopeAsImportingScope())
|
||||||
receiverClassDescriptor,
|
|
||||||
"Classifier resolution scope: ${receiverClassDescriptor.getName()}",
|
|
||||||
typeParamScope,
|
|
||||||
memberScope
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun collectSubstitutionsForReceiverTypeParameters(
|
private fun collectSubstitutionsForReceiverTypeParameters(
|
||||||
@@ -394,7 +390,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createFakeFunctionDescriptor(scope: KtScope, typeParameterCount: Int): FunctionDescriptor {
|
private fun createFakeFunctionDescriptor(scope: LexicalScope, typeParameterCount: Int): FunctionDescriptor {
|
||||||
val fakeFunction = SimpleFunctionDescriptorImpl.create(
|
val fakeFunction = SimpleFunctionDescriptorImpl.create(
|
||||||
MutablePackageFragmentDescriptor(currentFileModule, FqName("fake")),
|
MutablePackageFragmentDescriptor(currentFileModule, FqName("fake")),
|
||||||
Annotations.EMPTY,
|
Annotations.EMPTY,
|
||||||
@@ -616,7 +612,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
|||||||
else classBody.addAfter(declaration, classBody.lBrace!!) as KtNamedDeclaration
|
else classBody.addAfter(declaration, classBody.lBrace!!) as KtNamedDeclaration
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTypeParameterRenames(scope: KtScope): Map<TypeParameterDescriptor, String> {
|
private fun getTypeParameterRenames(scope: LexicalScope): Map<TypeParameterDescriptor, String> {
|
||||||
val allTypeParametersNotInScope = LinkedHashSet<TypeParameterDescriptor>()
|
val allTypeParametersNotInScope = LinkedHashSet<TypeParameterDescriptor>()
|
||||||
|
|
||||||
mandatoryTypeParametersAsCandidates.asSequence()
|
mandatoryTypeParametersAsCandidates.asSequence()
|
||||||
|
|||||||
+3
-2
@@ -34,7 +34,8 @@ import org.jetbrains.kotlin.resolve.BindingContext
|
|||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement
|
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.resolveTopLevelClass
|
import org.jetbrains.kotlin.resolve.descriptorUtil.resolveTopLevelClass
|
||||||
import org.jetbrains.kotlin.resolve.scopes.KtScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.utils.getClassifier
|
||||||
import org.jetbrains.kotlin.types.*
|
import org.jetbrains.kotlin.types.*
|
||||||
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker
|
||||||
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
import org.jetbrains.kotlin.types.typeUtil.makeNotNullable
|
||||||
@@ -79,7 +80,7 @@ private fun KotlinType.render(typeParameterNameMap: Map<TypeParameterDescriptor,
|
|||||||
internal fun KotlinType.renderShort(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, false)
|
internal fun KotlinType.renderShort(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, false)
|
||||||
internal fun KotlinType.renderLong(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, true)
|
internal fun KotlinType.renderLong(typeParameterNameMap: Map<TypeParameterDescriptor, String>) = render(typeParameterNameMap, true)
|
||||||
|
|
||||||
internal fun getTypeParameterNamesNotInScope(typeParameters: Collection<TypeParameterDescriptor>, scope: KtScope): List<TypeParameterDescriptor> {
|
internal fun getTypeParameterNamesNotInScope(typeParameters: Collection<TypeParameterDescriptor>, scope: LexicalScope): List<TypeParameterDescriptor> {
|
||||||
return typeParameters.filter { typeParameter ->
|
return typeParameters.filter { typeParameter ->
|
||||||
val classifier = scope.getClassifier(typeParameter.name, NoLookupLocation.FROM_IDE)
|
val classifier = scope.getClassifier(typeParameter.name, NoLookupLocation.FROM_IDE)
|
||||||
classifier == null || classifier != typeParameter
|
classifier == null || classifier != typeParameter
|
||||||
|
|||||||
Reference in New Issue
Block a user