Global replace JetScope to LexicalScope
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jetbrains.kotlin.resolve.BindingTraceContext
|
||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.asLexicalScope
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
import org.jetbrains.kotlin.types.expressions.ExpressionTypingContext
|
||||
@@ -73,7 +74,7 @@ public class IterableTypesDetection(
|
||||
|
||||
val expression = JetPsiFactory(project).createExpression("fake")
|
||||
val expressionReceiver = ExpressionReceiver(expression, type.type)
|
||||
val context = ExpressionTypingContext.newContext(BindingTraceContext(), scope, DataFlowInfo.EMPTY, TypeUtils.NO_EXPECTED_TYPE)
|
||||
val context = ExpressionTypingContext.newContext(BindingTraceContext(), scope.asLexicalScope(), DataFlowInfo.EMPTY, TypeUtils.NO_EXPECTED_TYPE)
|
||||
val elementType = forLoopConventionsChecker.checkIterableConvention(expressionReceiver, context)
|
||||
return elementType?.let { FuzzyType(it, type.freeParameters) }
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.psi.psiUtil.siblings
|
||||
import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import java.util.Collections
|
||||
import java.util.HashSet
|
||||
@@ -79,7 +80,7 @@ public class NewDeclarationNameValidator(
|
||||
if (visibleDeclarationsContext != null) {
|
||||
val bindingContext = visibleDeclarationsContext.analyze(BodyResolveMode.PARTIAL_FOR_COMPLETION)
|
||||
val resolutionScope = visibleDeclarationsContext.getResolutionScope(bindingContext, visibleDeclarationsContext.getResolutionFacade())
|
||||
if (resolutionScope.hasConflict(identifier)) return false
|
||||
if (resolutionScope.asJetScope().hasConflict(identifier)) return false
|
||||
}
|
||||
|
||||
return checkDeclarationsIn.none {
|
||||
|
||||
@@ -27,8 +27,9 @@ import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||
import org.jetbrains.kotlin.resolve.BindingContext
|
||||
import org.jetbrains.kotlin.resolve.scopes.JetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.asLexicalScope
|
||||
import java.util.*
|
||||
|
||||
public fun Call.mapArgumentsToParameters(targetDescriptor: CallableDescriptor): Map<ValueArgument, ValueParameterDescriptor> {
|
||||
@@ -80,17 +81,18 @@ public fun ThisReceiver.asExpression(resolutionScope: JetScope, psiFactory: JetP
|
||||
return expressionFactory.createExpression(psiFactory)
|
||||
}
|
||||
|
||||
public fun PsiElement.getResolutionScope(bindingContext: BindingContext, resolutionFacade: ResolutionFacade): JetScope {
|
||||
public fun PsiElement.getResolutionScope(bindingContext: BindingContext, resolutionFacade: ResolutionFacade): LexicalScope {
|
||||
for (parent in parentsWithSelf) {
|
||||
if (parent is JetExpression) {
|
||||
val scope = bindingContext[BindingContext.RESOLUTION_SCOPE, parent]
|
||||
val scope = bindingContext[BindingContext.LEXICAL_SCOPE, parent] ?:
|
||||
bindingContext[BindingContext.RESOLUTION_SCOPE, parent]?.asLexicalScope() // todo remove this hack
|
||||
if (scope != null) return scope
|
||||
}
|
||||
|
||||
if (parent is JetClassBody) {
|
||||
val classDescriptor = bindingContext[BindingContext.CLASS, parent.getParent()] as? ClassDescriptorWithResolutionScopes
|
||||
if (classDescriptor != null) {
|
||||
return classDescriptor.getScopeForMemberDeclarationResolution().asJetScope()
|
||||
return classDescriptor.getScopeForMemberDeclarationResolution()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user