diff --git a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt index 500679cf82d..ddaefebeb96 100644 --- a/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt +++ b/compiler/cli/src/org/jetbrains/kotlin/cli/jvm/compiler/CliLightClassGenerationSupport.kt @@ -181,7 +181,7 @@ public class CliLightClassGenerationSupport(project: Project) : LightClassGenera public class NoScopeRecordCliBindingTrace : CliBindingTrace() { override fun record(slice: WritableSlice, 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 } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java index 21e5d36a22a..852336feb28 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/BindingContext.java @@ -137,12 +137,8 @@ public interface BindingContext { WritableSlice EXHAUSTIVE_WHEN = Slices.createSimpleSlice(); - /** - * A scope where type of expression has been resolved - */ - WritableSlice TYPE_RESOLUTION_SCOPE = Slices.createSimpleSlice(); @Deprecated WritableSlice RESOLUTION_SCOPE = Slices.createSimpleSlice(); - WritableSlice LEXICAL_SCOPE = Slices.createSimpleSlice(); + WritableSlice LEXICAL_SCOPE = Slices.createSimpleSlice(); WritableSlice SCRIPT_SCOPE = Slices.createSimpleSlice(); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt index a7a796e73d2..395726b4bab 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/TypeResolver.kt @@ -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) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java index bc4bb93cf7f..16eaf73a2fa 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/types/expressions/BasicExpressionTypingVisitor.java @@ -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; } diff --git a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt index ce45a1396c9..891a7f3436e 100644 --- a/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt +++ b/idea/ide-common/src/org/jetbrains/kotlin/idea/codeInsight/ReferenceVariantsHelper.kt @@ -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(strict = true)?.let { - context[BindingContext.TYPE_RESOLUTION_SCOPE, it] + context[BindingContext.LEXICAL_SCOPE, it] } ?: return emptyList() return lexicalScope.getDescriptorsFiltered(accurateKindFilter, nameFilter) } diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ShortenReferences.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ShortenReferences.kt index fd97eac9ee4..277afa2e7f6 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ShortenReferences.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/util/ShortenReferences.kt @@ -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()!! - 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)