Minor. Replaced TYPE_RESOLUTION_SCOPE to LEXICAL_SCOPE
This commit is contained in:
+1
-1
@@ -181,7 +181,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera
|
||||
|
||||
public class NoScopeRecordCliBindingTrace : CliBindingTrace() {
|
||||
override fun <K, V> record(slice: WritableSlice<K, V>, key: K, value: V) {
|
||||
if (slice === BindingContext.RESOLUTION_SCOPE || slice === BindingContext.TYPE_RESOLUTION_SCOPE || slice === BindingContext.LEXICAL_SCOPE) {
|
||||
if (slice === BindingContext.RESOLUTION_SCOPE || slice === BindingContext.LEXICAL_SCOPE) {
|
||||
// In the compiler there's no need to keep scopes
|
||||
return
|
||||
}
|
||||
|
||||
@@ -137,12 +137,8 @@ public interface BindingContext {
|
||||
|
||||
WritableSlice<JetWhenExpression, Boolean> EXHAUSTIVE_WHEN = Slices.createSimpleSlice();
|
||||
|
||||
/**
|
||||
* A scope where type of expression has been resolved
|
||||
*/
|
||||
WritableSlice<JetTypeReference, JetScope> TYPE_RESOLUTION_SCOPE = Slices.createSimpleSlice();
|
||||
@Deprecated WritableSlice<JetExpression, JetScope> RESOLUTION_SCOPE = Slices.createSimpleSlice();
|
||||
WritableSlice<JetExpression, LexicalScope> LEXICAL_SCOPE = Slices.createSimpleSlice();
|
||||
WritableSlice<JetElement, LexicalScope> LEXICAL_SCOPE = Slices.createSimpleSlice();
|
||||
|
||||
WritableSlice<ScriptDescriptor, JetScope> SCRIPT_SCOPE = Slices.createSimpleSlice();
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ public class TypeResolver(
|
||||
val typeElement = typeReference.getTypeElement()
|
||||
|
||||
val type = resolveTypeElement(c, annotations, typeElement)
|
||||
c.trace.record(BindingContext.TYPE_RESOLUTION_SCOPE, typeReference, c.scope.asJetScope())
|
||||
c.trace.record(BindingContext.LEXICAL_SCOPE, typeReference, c.scope)
|
||||
|
||||
if (!type.isBare) {
|
||||
for (argument in type.actualType.arguments) {
|
||||
|
||||
+1
-1
@@ -429,7 +429,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
context.trace.record(BindingContext.REFERENCE_TARGET, expression.getInstanceReference(), result.getConstructor().getDeclarationDescriptor());
|
||||
}
|
||||
if (superTypeQualifier != null) {
|
||||
context.trace.record(BindingContext.TYPE_RESOLUTION_SCOPE, superTypeQualifier, asJetScope(context.scope));
|
||||
context.trace.record(BindingContext.LEXICAL_SCOPE, superTypeQualifier, context.scope);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+2
-1
@@ -44,6 +44,7 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension
|
||||
import org.jetbrains.kotlin.resolve.scopes.*
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ExpressionReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.getDescriptorsFiltered
|
||||
import org.jetbrains.kotlin.synthetic.SyntheticJavaPropertyDescriptor
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
import org.jetbrains.kotlin.types.TypeUtils
|
||||
@@ -178,7 +179,7 @@ public class ReferenceVariantsHelper(
|
||||
}
|
||||
else {
|
||||
val lexicalScope = expression.getParentOfType<JetTypeReference>(strict = true)?.let {
|
||||
context[BindingContext.TYPE_RESOLUTION_SCOPE, it]
|
||||
context[BindingContext.LEXICAL_SCOPE, it]
|
||||
} ?: return emptyList()
|
||||
return lexicalScope.getDescriptorsFiltered(accurateKindFilter, nameFilter)
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getCalleeExpressionIfAny
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ThisReceiver
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.getClassifier
|
||||
import org.jetbrains.kotlin.resolve.scopes.utils.getFileScope
|
||||
import java.util.ArrayList
|
||||
import java.util.LinkedHashSet
|
||||
|
||||
@@ -271,9 +273,11 @@ public class ShortenReferences(val options: (JetElement) -> Options = { Options.
|
||||
val target = referenceExpression.targets(bindingContext).singleOrNull() ?: return
|
||||
|
||||
val typeReference = type.getStrictParentOfType<JetTypeReference>()!!
|
||||
val scope = bindingContext[BindingContext.TYPE_RESOLUTION_SCOPE, typeReference] ?: return
|
||||
val scope = bindingContext[BindingContext.LEXICAL_SCOPE, typeReference] ?: return
|
||||
val name = target.getName()
|
||||
val targetByName = if (target is ClassifierDescriptor) scope.getClassifier(name, NoLookupLocation.FROM_IDE) else scope.getPackage(name)
|
||||
val targetByName = if (target is ClassifierDescriptor) scope.getClassifier(name, NoLookupLocation.FROM_IDE) else {
|
||||
scope.getFileScope().getPackage(name)
|
||||
}
|
||||
val canShortenNow = targetByName?.asString() == target.asString()
|
||||
|
||||
processQualifiedElement(type, target, canShortenNow)
|
||||
|
||||
Reference in New Issue
Block a user