WritableScope: removed addLabeledDeclarations
This commit is contained in:
+1
-2
@@ -72,7 +72,7 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
|
||||
RedeclarationHandler redeclarationHandler = RedeclarationHandler.DO_NOTHING;
|
||||
|
||||
setScopeForMemberLookup(new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, redeclarationHandler, "MemberLookup")
|
||||
setScopeForMemberLookup(new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, redeclarationHandler, "MemberLookup", this)
|
||||
.changeLockLevel(WritableScope.LockLevel.BOTH));
|
||||
this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler, "SupertypeResolution")
|
||||
.changeLockLevel(WritableScope.LockLevel.BOTH);
|
||||
@@ -84,7 +84,6 @@ public class MutableClassDescriptor extends ClassDescriptorBase implements Class
|
||||
}
|
||||
|
||||
this.scopeForMemberResolution = new ChainedScope(this, "MemberResolutionWithStatic", writableScopeForMemberResolution, staticScope);
|
||||
writableScopeForMemberResolution.addLabeledDeclaration(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -134,8 +134,11 @@ class FunctionDescriptorResolver(
|
||||
trace: BindingTrace,
|
||||
expectedFunctionType: JetType
|
||||
) {
|
||||
val innerScope = WritableScopeImpl(scope, functionDescriptor, TraceBasedRedeclarationHandler(trace), "Function descriptor header scope")
|
||||
innerScope.addLabeledDeclaration(functionDescriptor)
|
||||
val innerScope = WritableScopeImpl(scope,
|
||||
functionDescriptor,
|
||||
TraceBasedRedeclarationHandler(trace),
|
||||
"Function descriptor header scope",
|
||||
labeledDeclaration = functionDescriptor)
|
||||
|
||||
val typeParameterDescriptors = descriptorResolver.
|
||||
resolveTypeParametersForCallableDescriptor(functionDescriptor, innerScope, function.getTypeParameters(), trace)
|
||||
|
||||
@@ -80,7 +80,7 @@ public class FunctionDescriptorUtil {
|
||||
@NotNull FunctionDescriptor descriptor,
|
||||
@NotNull RedeclarationHandler redeclarationHandler
|
||||
) {
|
||||
WritableScope parameterScope = new WritableScopeImpl(outerScope, descriptor, redeclarationHandler, "Function inner scope");
|
||||
WritableScope parameterScope = new WritableScopeImpl(outerScope, descriptor, redeclarationHandler, "Function inner scope", descriptor);
|
||||
ReceiverParameterDescriptor receiver = descriptor.getExtensionReceiverParameter();
|
||||
if (receiver != null) {
|
||||
parameterScope.setImplicitReceiver(receiver);
|
||||
@@ -91,7 +91,6 @@ public class FunctionDescriptorUtil {
|
||||
for (ValueParameterDescriptor valueParameterDescriptor : descriptor.getValueParameters()) {
|
||||
parameterScope.addVariableDescriptor(valueParameterDescriptor);
|
||||
}
|
||||
parameterScope.addLabeledDeclaration(descriptor);
|
||||
parameterScope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
return parameterScope;
|
||||
}
|
||||
|
||||
+2
-2
@@ -265,8 +265,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
|
||||
@NotNull
|
||||
private JetScope computeScopeForMemberDeclarationResolution() {
|
||||
WritableScopeImpl thisScope = new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, RedeclarationHandler.DO_NOTHING, "Scope with 'this' for " + getName());
|
||||
thisScope.addLabeledDeclaration(this);
|
||||
WritableScopeImpl thisScope = new WritableScopeImpl(JetScope.Empty.INSTANCE$, this, RedeclarationHandler.DO_NOTHING,
|
||||
"Scope with 'this' for " + getName(), this);
|
||||
thisScope.setImplicitReceiver(this.getThisAsReceiverParameter());
|
||||
thisScope.changeLockLevel(WritableScope.LockLevel.READING);
|
||||
|
||||
|
||||
@@ -126,10 +126,8 @@ public final class JetScopeUtils {
|
||||
) {
|
||||
WritableScopeImpl result = new WritableScopeImpl(
|
||||
outerScope, propertyDescriptor, redeclarationHandler,
|
||||
"Property declaration inner scope");
|
||||
if (addLabelForProperty) {
|
||||
result.addLabeledDeclaration(propertyDescriptor);
|
||||
}
|
||||
"Property declaration inner scope",
|
||||
addLabelForProperty ? propertyDescriptor : null);
|
||||
for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) {
|
||||
result.addClassifierDescriptor(typeParameterDescriptor);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@ public trait WritableScope : JetScope {
|
||||
|
||||
public fun changeLockLevel(lockLevel: LockLevel): WritableScope
|
||||
|
||||
public fun addLabeledDeclaration(descriptor: DeclarationDescriptor)
|
||||
|
||||
public fun addVariableDescriptor(variableDescriptor: VariableDescriptor)
|
||||
|
||||
public fun addFunctionDescriptor(functionDescriptor: FunctionDescriptor)
|
||||
|
||||
@@ -32,11 +32,13 @@ import org.jetbrains.kotlin.util.collectionUtils.concatInOrder
|
||||
|
||||
// Writes to: maps
|
||||
|
||||
public class WritableScopeImpl(outerScope: JetScope,
|
||||
private val ownerDeclarationDescriptor: DeclarationDescriptor,
|
||||
protected val redeclarationHandler: RedeclarationHandler,
|
||||
private val debugName: String)
|
||||
: AbstractScopeAdapter(), WritableScope {
|
||||
public class WritableScopeImpl @jvmOverloads constructor(
|
||||
outerScope: JetScope,
|
||||
private val ownerDeclarationDescriptor: DeclarationDescriptor,
|
||||
protected val redeclarationHandler: RedeclarationHandler,
|
||||
private val debugName: String,
|
||||
private val labeledDeclaration: DeclarationDescriptor? = null
|
||||
) : AbstractScopeAdapter(), WritableScope {
|
||||
|
||||
private val explicitlyAddedDescriptors = SmartList<DeclarationDescriptor>()
|
||||
|
||||
@@ -44,8 +46,6 @@ public class WritableScopeImpl(outerScope: JetScope,
|
||||
|
||||
private var variableOrClassDescriptors: MutableMap<Name, IntList>? = null
|
||||
|
||||
private var labelsToDescriptors: MutableMap<Name, SmartList<DeclarationDescriptor>>? = null
|
||||
|
||||
private var implicitReceiver: ReceiverParameterDescriptor? = null
|
||||
|
||||
private var implicitReceiverHierarchy: List<ReceiverParameterDescriptor>? = null
|
||||
@@ -101,18 +101,10 @@ public class WritableScopeImpl(outerScope: JetScope,
|
||||
checkMayRead()
|
||||
|
||||
val superResult = super<AbstractScopeAdapter>.getDeclarationsByLabel(labelName)
|
||||
val declarationDescriptors = labelsToDescriptors?.get(labelName) ?: return superResult
|
||||
if (superResult.isEmpty()) return declarationDescriptors
|
||||
return declarationDescriptors + superResult
|
||||
}
|
||||
|
||||
override fun addLabeledDeclaration(descriptor: DeclarationDescriptor) {
|
||||
checkMayWrite()
|
||||
|
||||
if (labelsToDescriptors == null) {
|
||||
labelsToDescriptors = HashMap()
|
||||
}
|
||||
labelsToDescriptors!!.getOrPut(descriptor.getName()) { SmartList() }.add(descriptor)
|
||||
return if (labeledDeclaration != null && labeledDeclaration.getName() == labelName)
|
||||
listOf(labeledDeclaration) + superResult
|
||||
else
|
||||
superResult
|
||||
}
|
||||
|
||||
private fun addVariableOrClassDescriptor(descriptor: DeclarationDescriptor) {
|
||||
|
||||
Reference in New Issue
Block a user