diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java index 8044d6b2dde..13947a18c05 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/FunctionDescriptorUtil.java @@ -104,7 +104,7 @@ public class FunctionDescriptorUtil { @NotNull public static JetScope getFunctionInnerScope(@NotNull JetScope outerScope, @NotNull FunctionDescriptor descriptor, @NotNull BindingTrace trace) { - WritableScope parameterScope = new WritableScopeImpl(outerScope, descriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Function inner scope"); + WritableScope parameterScope = new WritableScopeImpl(outerScope, descriptor, new TraceBasedRedeclarationHandler(trace), "Function inner scope"); ReceiverDescriptor receiver = descriptor.getReceiverParameter(); if (receiver.exists()) { parameterScope.setImplicitReceiver(receiver); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java index ba6fe22b229..f5dbf5d9e42 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/MutableClassDescriptor.java @@ -53,14 +53,11 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite { RedeclarationHandler redeclarationHandler = RedeclarationHandler.DO_NOTHING; - setScopeForMemberLookup(new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler) - .setDebugName("MemberLookup") + setScopeForMemberLookup(new WritableScopeImpl(JetScope.EMPTY, this, redeclarationHandler, "MemberLookup") .changeLockLevel(WritableScope.LockLevel.BOTH)); - this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler) - .setDebugName("SupertypeResolution") + this.scopeForSupertypeResolution = new WritableScopeImpl(outerScope, this, redeclarationHandler, "SupertypeResolution") .changeLockLevel(WritableScope.LockLevel.BOTH); - this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler) - .setDebugName("MemberResolution") + this.scopeForMemberResolution = new WritableScopeImpl(scopeForSupertypeResolution, this, redeclarationHandler, "MemberResolution") .changeLockLevel(WritableScope.LockLevel.BOTH); if (getKind() == ClassKind.TRAIT) { setUpScopeForInitializers(this); @@ -153,7 +150,9 @@ public class MutableClassDescriptor extends MutableClassDescriptorLite { } private void setUpScopeForInitializers(@NotNull DeclarationDescriptor containingDeclaration) { - this.scopeForInitializers = new WritableScopeImpl(scopeForMemberResolution, containingDeclaration, RedeclarationHandler.DO_NOTHING).setDebugName("Initializers").changeLockLevel(WritableScope.LockLevel.BOTH); + this.scopeForInitializers = new WritableScopeImpl( + scopeForMemberResolution, containingDeclaration, RedeclarationHandler.DO_NOTHING, "Initializers") + .changeLockLevel(WritableScope.LockLevel.BOTH); } @Override diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java index 41851327731..5981aae0f81 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BodyResolver.java @@ -526,7 +526,8 @@ public class BodyResolver { JetScope propertyDeclarationInnerScope = descriptorResolver.getPropertyDeclarationInnerScope( declaringScope, propertyDescriptor.getTypeParameters(), propertyDescriptor.getReceiverParameter(), trace); - WritableScope accessorScope = new WritableScopeImpl(propertyDeclarationInnerScope, declaringScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(trace)).setDebugName("Accessor scope"); + WritableScope accessorScope = new WritableScopeImpl( + propertyDeclarationInnerScope, declaringScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(trace), "Accessor scope"); accessorScope.changeLockLevel(WritableScope.LockLevel.READING); return accessorScope; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java index 2b1ff4a9a5a..655b3cf00a1 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java @@ -183,7 +183,7 @@ public class DescriptorResolver { JetPsiUtil.safeName(function.getName()), CallableMemberDescriptor.Kind.DECLARATION ); - WritableScope innerScope = new WritableScopeImpl(scope, functionDescriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Function descriptor header scope"); + WritableScope innerScope = new WritableScopeImpl(scope, functionDescriptor, new TraceBasedRedeclarationHandler(trace), "Function descriptor header scope"); innerScope.addLabeledDeclaration(functionDescriptor); List typeParameterDescriptors = resolveTypeParameters(functionDescriptor, innerScope, function.getTypeParameters(), trace); @@ -586,7 +586,8 @@ public class DescriptorResolver { public JetScope getPropertyDeclarationInnerScope(@NotNull JetScope outerScope, @NotNull List typeParameters, @NotNull ReceiverDescriptor receiver, BindingTrace trace) { - WritableScopeImpl result = new WritableScopeImpl(outerScope, outerScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(trace)).setDebugName("Property declaration inner scope"); + WritableScopeImpl result = new WritableScopeImpl( + outerScope, outerScope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(trace), "Property declaration inner scope"); for (TypeParameterDescriptor typeParameterDescriptor : typeParameters) { result.addTypeParameterDescriptor(typeParameterDescriptor); } @@ -627,7 +628,8 @@ public class DescriptorResolver { typeParameterDescriptors = Collections.emptyList(); } else { - WritableScope writableScope = new WritableScopeImpl(scope, containingDeclaration, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with type parameters of a property"); + WritableScope writableScope = new WritableScopeImpl( + scope, containingDeclaration, new TraceBasedRedeclarationHandler(trace), "Scope with type parameters of a property"); typeParameterDescriptors = resolveTypeParameters(containingDeclaration, writableScope, typeParameters, trace); writableScope.changeLockLevel(WritableScope.LockLevel.READING); resolveGenericBounds(property, writableScope, typeParameterDescriptors, trace); @@ -882,7 +884,8 @@ public class DescriptorResolver { isPrimary ); trace.record(BindingContext.CONSTRUCTOR, declarationToTrace, constructorDescriptor); - WritableScopeImpl parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)).setDebugName("Scope with value parameters of a constructor"); + WritableScopeImpl parameterScope = new WritableScopeImpl( + scope, classDescriptor, new TraceBasedRedeclarationHandler(trace), "Scope with value parameters of a constructor"); parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH); return constructorDescriptor.initialize( typeParameters, diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/NamespaceFactoryImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/NamespaceFactoryImpl.java index 94dc1670cc3..84c5025299e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/NamespaceFactoryImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/NamespaceFactoryImpl.java @@ -187,7 +187,7 @@ public class NamespaceFactoryImpl implements NamespaceFactory { ); trace.record(FQNAME_TO_NAMESPACE_DESCRIPTOR, fqName, namespaceDescriptor); - WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, handler).setDebugName("Namespace member scope"); + WritableScopeImpl scope = new WritableScopeImpl(JetScope.EMPTY, namespaceDescriptor, handler, "Namespace member scope"); scope.changeLockLevel(WritableScope.LockLevel.BOTH); namespaceDescriptor.initialize(scope); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptResolver.java index 30312b2e2af..9fff7dd839f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/ScriptResolver.java @@ -138,7 +138,7 @@ public class ScriptResolver { ScriptDescriptor scriptDescriptor = new ScriptDescriptor(ns); //WriteThroughScope scriptScope = new WriteThroughScope( // outerScope, ns.getMemberScope(), new TraceBasedRedeclarationHandler(trace)); - WritableScopeImpl scriptScope = new WritableScopeImpl(outerScope, scriptDescriptor, RedeclarationHandler.DO_NOTHING); + WritableScopeImpl scriptScope = new WritableScopeImpl(outerScope, scriptDescriptor, RedeclarationHandler.DO_NOTHING, "script"); scriptScope.changeLockLevel(WritableScope.LockLevel.BOTH); context.getScriptScopes().put(script, scriptScope); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java index 8ffe011e986..c6ef9fac2e2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TopDownAnalyzer.java @@ -276,7 +276,7 @@ public class TopDownAnalyzer { @NotNull List scriptParameters) { final WritableScope scope = new WritableScopeImpl( JetScope.EMPTY, moduleDescriptor, - new TraceBasedRedeclarationHandler(trace)).setDebugName("Root scope in analyzeNamespace"); + new TraceBasedRedeclarationHandler(trace), "Root scope in analyzeNamespace"); scope.changeLockLevel(WritableScope.LockLevel.BOTH); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java index 9b40bd5dfaf..26f6f94d0f9 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/TypeHierarchyResolver.java @@ -205,7 +205,7 @@ public class TypeHierarchyResolver { context.getNamespaceDescriptors().put(file, namespaceDescriptor); WriteThroughScope namespaceScope = new WriteThroughScope(outerScope, namespaceDescriptor.getMemberScope(), - new TraceBasedRedeclarationHandler(trace)); + new TraceBasedRedeclarationHandler(trace), "namespace"); namespaceScope.changeLockLevel(WritableScope.LockLevel.BOTH); context.getNamespaceScopes().put(file, namespaceScope); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/LazyClassDescriptor.java index da16661e5da..fecfccb294a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/LazyClassDescriptor.java @@ -111,8 +111,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes @NotNull public JetScope getScopeForClassHeaderResolution() { if (scopeForClassHeaderResolution == null) { - WritableScopeImpl scope = new WritableScopeImpl(resolveSession.getResolutionScope(declarationProvider.getOwnerClassOrObject()), this, RedeclarationHandler.DO_NOTHING) - .setDebugName("Class Header Resolution"); + WritableScopeImpl scope = new WritableScopeImpl( + resolveSession.getResolutionScope(declarationProvider.getOwnerClassOrObject()), this, RedeclarationHandler.DO_NOTHING, "Class Header Resolution"); for (TypeParameterDescriptor typeParameterDescriptor : getTypeConstructor().getParameters()) { scope.addClassifierDescriptor(typeParameterDescriptor); } @@ -124,8 +124,8 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes public JetScope getScopeForMemberDeclarationResolution() { if (scopeForMemberDeclarationResolution == null) { - WritableScopeImpl scope = new WritableScopeImpl(getScopeForClassHeaderResolution(), this, RedeclarationHandler.DO_NOTHING) - .setDebugName("Member Declaration Resolution"); + WritableScopeImpl scope = new WritableScopeImpl( + getScopeForClassHeaderResolution(), this, RedeclarationHandler.DO_NOTHING, "Member Declaration Resolution"); // TODO : supertypes etc diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/ScopeProvider.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/ScopeProvider.java index ad0f3d64d2e..62694b72619 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/ScopeProvider.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/lazy/ScopeProvider.java @@ -58,7 +58,8 @@ public class ScopeProvider { throw new IllegalStateException("Package not found: " + fqName + " maybe the file is not in scope of this resolve session: " + file.getName()); } - WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, packageDescriptor, RedeclarationHandler.DO_NOTHING); + WritableScope writableScope = new WritableScopeImpl( + JetScope.EMPTY, packageDescriptor, RedeclarationHandler.DO_NOTHING, "file scope for declaration resollution"); writableScope.importScope(packageDescriptor.getMemberScope()); // TODO: imports @@ -75,7 +76,8 @@ public class ScopeProvider { JetScope memberScope = classDescriptor.getDefaultType().getMemberScope(); JetScope outerScope = getResolutionScopeForDeclaration((JetDeclaration) classOrObject); - WritableScope typeParametersScope = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, RedeclarationHandler.DO_NOTHING); + WritableScope typeParametersScope = new WritableScopeImpl( + JetScope.EMPTY, classDescriptor, RedeclarationHandler.DO_NOTHING, "scope for class member resolution"); for (TypeParameterDescriptor typeParameterDescriptor : classDescriptor.getTypeConstructor().getParameters()) { typeParametersScope.addClassifierDescriptor(typeParameterDescriptor); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java index c12f281453b..0921b61a23d 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeImpl.java @@ -66,8 +66,9 @@ public class WritableScopeImpl extends WritableScopeWithImports { @Nullable private ReceiverDescriptor implicitReceiver; - public WritableScopeImpl(@NotNull JetScope scope, @NotNull DeclarationDescriptor owner, @NotNull RedeclarationHandler redeclarationHandler) { - super(scope, redeclarationHandler); + public WritableScopeImpl(@NotNull JetScope scope, @NotNull DeclarationDescriptor owner, + @NotNull RedeclarationHandler redeclarationHandler, @NotNull String debugName) { + super(scope, redeclarationHandler, debugName); this.ownerDeclarationDescriptor = owner; } @@ -519,14 +520,6 @@ public class WritableScopeImpl extends WritableScopeWithImports { return variableClassOrNamespaceDescriptors != null && !variableClassOrNamespaceDescriptors.isEmpty(); } - @Override - public WritableScopeImpl setDebugName(@NotNull String debugName) { - checkMayWrite(); - - super.setDebugName(debugName); - return this; - } - private void addToDeclared(DeclarationDescriptor descriptor) { declaredDescriptorsAccessibleBySimpleName.put(descriptor.getName(), descriptor); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java index 9a291d6291f..4711cb84195 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WritableScopeWithImports.java @@ -33,16 +33,18 @@ import java.util.Set; */ public abstract class WritableScopeWithImports extends JetScopeAdapter implements WritableScope { - private String debugName; + @NotNull + private final String debugName; @Nullable private List imports; private WritableScope currentIndividualImportScope; protected final RedeclarationHandler redeclarationHandler; - public WritableScopeWithImports(@NotNull JetScope scope, @NotNull RedeclarationHandler redeclarationHandler) { + public WritableScopeWithImports(@NotNull JetScope scope, @NotNull RedeclarationHandler redeclarationHandler, @NotNull String debugName) { super(scope); this.redeclarationHandler = redeclarationHandler; + this.debugName = debugName; } @@ -79,14 +81,6 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement - public WritableScopeWithImports setDebugName(@NotNull String debugName) { - checkMayWrite(); - - assert this.debugName == null : this.debugName; - this.debugName = debugName; - return this; - } - @NotNull protected final List getImports() { if (imports == null) { @@ -205,7 +199,7 @@ public abstract class WritableScopeWithImports extends JetScopeAdapter implement private WritableScope getCurrentIndividualImportScope() { if (currentIndividualImportScope == null) { - WritableScopeImpl writableScope = new WritableScopeImpl(EMPTY, getContainingDeclaration(), RedeclarationHandler.DO_NOTHING).setDebugName("Individual import scope"); + WritableScopeImpl writableScope = new WritableScopeImpl(EMPTY, getContainingDeclaration(), RedeclarationHandler.DO_NOTHING, "Individual import scope"); writableScope.changeLockLevel(LockLevel.BOTH); importScope(writableScope); currentIndividualImportScope = writableScope; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java index 2a587fd8e90..136dbf78dc5 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/scopes/WriteThroughScope.java @@ -36,8 +36,9 @@ public class WriteThroughScope extends WritableScopeWithImports { private final WritableScope writableWorker; private Collection allDescriptors; - public WriteThroughScope(@NotNull JetScope outerScope, @NotNull WritableScope scope, @NotNull RedeclarationHandler redeclarationHandler) { - super(outerScope, redeclarationHandler); + public WriteThroughScope(@NotNull JetScope outerScope, @NotNull WritableScope scope, + @NotNull RedeclarationHandler redeclarationHandler, @NotNull String debugName) { + super(outerScope, redeclarationHandler, debugName); this.writableWorker = scope; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index 06095b8f2f9..37dafad2743 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -968,11 +968,11 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { } else if (operationType == JetTokens.ANDAND || operationType == JetTokens.OROR) { JetType leftType = facade.getType(left, context.replaceScope(context.scope)); - WritableScopeImpl leftScope = newWritableScopeImpl(context).setDebugName("Left scope of && or ||"); + WritableScopeImpl leftScope = newWritableScopeImpl(context, "Left scope of && or ||"); DataFlowInfo flowInfoLeft = DataFlowUtils.extractDataFlowInfoFromCondition(left, operationType == JetTokens.ANDAND, leftScope, context); // TODO: This gets computed twice: here and in extractDataFlowInfoFromCondition() for the whole condition WritableScopeImpl rightScope = operationType == JetTokens.ANDAND ? leftScope - : newWritableScopeImpl(context).setDebugName("Right scope of && or ||"); + : newWritableScopeImpl(context, "Right scope of && or ||"); JetType rightType = right == null ? null : facade.getType(right, context.replaceDataFlowInfo(flowInfoLeft).replaceScope(rightScope)); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java index c77b33a35ba..c5acf6daa01 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java @@ -89,8 +89,8 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { JetExpression elseBranch = expression.getElse(); JetExpression thenBranch = expression.getThen(); - WritableScopeImpl thenScope = newWritableScopeImpl(context).setDebugName("Then scope"); - WritableScopeImpl elseScope = newWritableScopeImpl(context).setDebugName("Else scope"); + WritableScopeImpl thenScope = newWritableScopeImpl(context, "Then scope"); + WritableScopeImpl elseScope = newWritableScopeImpl(context, "Else scope"); DataFlowInfo thenInfo = DataFlowUtils.extractDataFlowInfoFromCondition(condition, true, thenScope, context); DataFlowInfo elseInfo = DataFlowUtils.extractDataFlowInfoFromCondition(condition, false, null, context); @@ -152,7 +152,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { checkCondition(context.scope, condition, context); JetExpression body = expression.getBody(); if (body != null) { - WritableScopeImpl scopeToExtend = newWritableScopeImpl(context).setDebugName("Scope extended in while's condition"); + WritableScopeImpl scopeToExtend = newWritableScopeImpl(context, "Scope extended in while's condition"); DataFlowInfo conditionInfo = condition == null ? context.dataFlowInfo : DataFlowUtils.extractDataFlowInfoFromCondition(condition, true, scopeToExtend, context); context.expressionTypingServices.getBlockReturnedTypeWithWritableScope(scopeToExtend, Collections.singletonList(body), CoercionStrategy.NO_COERCION, context.replaceDataFlowInfo(conditionInfo), context.trace); } @@ -199,7 +199,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { if (body instanceof JetFunctionLiteralExpression) { JetFunctionLiteralExpression function = (JetFunctionLiteralExpression) body; if (!function.getFunctionLiteral().hasParameterSpecification()) { - WritableScope writableScope = newWritableScopeImpl(context).setDebugName("do..while body scope"); + WritableScope writableScope = newWritableScopeImpl(context, "do..while body scope"); conditionScope = writableScope; context.expressionTypingServices.getBlockReturnedTypeWithWritableScope(writableScope, function.getFunctionLiteral().getBodyExpression().getStatements(), CoercionStrategy.NO_COERCION, context, context.trace); context.trace.record(BindingContext.BLOCK, function); @@ -209,7 +209,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { } } else if (body != null) { - WritableScope writableScope = newWritableScopeImpl(context).setDebugName("do..while body scope"); + WritableScope writableScope = newWritableScopeImpl(context, "do..while body scope"); conditionScope = writableScope; List block; if (body instanceof JetBlockExpression) { @@ -247,7 +247,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { } } - WritableScope loopScope = newWritableScopeImpl(context).setDebugName("Scope with for-loop index"); + WritableScope loopScope = newWritableScopeImpl(context, "Scope with for-loop index"); if (loopParameter != null) { JetTypeReference typeReference = loopParameter.getTypeReference(); @@ -417,7 +417,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { JetType throwableType = JetStandardLibrary.getInstance().getThrowable().getDefaultType(); DataFlowUtils.checkType(variableDescriptor.getType(), catchParameter, context.replaceExpectedType(throwableType)); if (catchBody != null) { - WritableScope catchScope = newWritableScopeImpl(context).setDebugName("Catch scope"); + WritableScope catchScope = newWritableScopeImpl(context, "Catch scope"); catchScope.addVariableDescriptor(variableDescriptor); JetType type = facade.getType(catchBody, context.replaceScope(catchScope)); if (type != null) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java index 582247093d4..ca740805b10 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java @@ -201,7 +201,8 @@ public class ExpressionTypingServices { containingDescriptor = ((ScriptDescriptor) containingDescriptor).getScriptCodeDescriptor(); } } - WritableScope scope = new WritableScopeImpl(outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace)).setDebugName("getBlockReturnedType"); + WritableScope scope = new WritableScopeImpl( + outerScope, containingDescriptor, new TraceBasedRedeclarationHandler(context.trace), "getBlockReturnedType"); scope.changeLockLevel(WritableScope.LockLevel.BOTH); return getBlockReturnedTypeWithWritableScope(scope, block, coercionStrategyForLastExpression, context, trace); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java index 0193651601c..cfc41223a1b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java @@ -78,8 +78,9 @@ public class ExpressionTypingUtils { } @NotNull - public static WritableScopeImpl newWritableScopeImpl(ExpressionTypingContext context) { - WritableScopeImpl scope = new WritableScopeImpl(context.scope, context.scope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.trace)); + public static WritableScopeImpl newWritableScopeImpl(ExpressionTypingContext context, @NotNull String scopeDebugName) { + WritableScopeImpl scope = new WritableScopeImpl( + context.scope, context.scope.getContainingDeclaration(), new TraceBasedRedeclarationHandler(context.trace), scopeDebugName); scope.changeLockLevel(WritableScope.LockLevel.BOTH); return scope; } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.java index 23008b0ad7f..adaa378f9ad 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingVisitorDispatcher.java @@ -115,7 +115,7 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitoremptyList(), Name.identifier("Tuple" + i)); - WritableScopeImpl writableScope = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, RedeclarationHandler.THROW_EXCEPTION); + WritableScopeImpl writableScope = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, RedeclarationHandler.THROW_EXCEPTION, "tuples"); for (int j = 0; j < i; j++) { TypeParameterDescriptor typeParameterDescriptor = TypeParameterDescriptorImpl.createWithDefaultBound( classDescriptor, @@ -229,7 +229,7 @@ public class JetStandardClasses { } private static WritableScope createScopeForInvokeFunction(ClassDescriptorImpl function, SimpleFunctionDescriptorImpl invoke) { - WritableScope scopeForInvoke = new WritableScopeImpl(STUB, function, RedeclarationHandler.THROW_EXCEPTION).setDebugName("Scope for function type"); + WritableScope scopeForInvoke = new WritableScopeImpl(STUB, function, RedeclarationHandler.THROW_EXCEPTION, "Scope for function type"); scopeForInvoke.addFunctionDescriptor(invoke); scopeForInvoke.changeLockLevel(WritableScope.LockLevel.READING); return scopeForInvoke; @@ -262,7 +262,7 @@ public class JetStandardClasses { public static final Name UNIT_ALIAS = Name.identifier("Unit"); static { - WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.DO_NOTHING).setDebugName("JetStandardClasses.STANDARD_CLASSES"); + WritableScope writableScope = new WritableScopeImpl(JetScope.EMPTY, STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.DO_NOTHING, "JetStandardClasses.STANDARD_CLASSES"); writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); STANDARD_CLASSES = writableScope; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/JetStandardLibrary.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/JetStandardLibrary.java index 89819d31bae..677ed82ff0c 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/JetStandardLibrary.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/lang/JetStandardLibrary.java @@ -145,7 +145,9 @@ public class JetStandardLibrary { } BindingTraceContext bindingTraceContext = new BindingTraceContext(); - WritableScopeImpl writableScope = new WritableScopeImpl(JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, RedeclarationHandler.THROW_EXCEPTION).setDebugName("Root bootstrap scope"); + WritableScopeImpl writableScope = new WritableScopeImpl( + JetStandardClasses.STANDARD_CLASSES, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, + RedeclarationHandler.THROW_EXCEPTION, "Root bootstrap scope"); writableScope.changeLockLevel(WritableScope.LockLevel.BOTH); TopDownAnalyzer.processStandardLibraryNamespace(project, bindingTraceContext, writableScope, JetStandardClasses.STANDARD_CLASSES_NAMESPACE, files); diff --git a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java index 54aadae3d02..c7e687d811f 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetDefaultModalityModifiersTest.java @@ -70,7 +70,8 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture { Collections.emptyList(), myEnvironment.getCompilerDependencies()); DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass); - WritableScopeImpl scope = new WritableScopeImpl(libraryScope, root, RedeclarationHandler.DO_NOTHING); + WritableScopeImpl scope = new WritableScopeImpl( + libraryScope, root, RedeclarationHandler.DO_NOTHING, "JetDefaultModalityModifiersTest"); assert classDescriptor instanceof ClassifierDescriptor; scope.addClassifierDescriptor((ClassifierDescriptor) classDescriptor); scope.changeLockLevel(WritableScope.LockLevel.READING); diff --git a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java index e27e075ff51..19b721ba5d3 100644 --- a/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java +++ b/compiler/tests/org/jetbrains/jet/types/JetTypeCheckerTest.java @@ -590,7 +590,8 @@ public class JetTypeCheckerTest extends JetLiteFixture { } private WritableScopeImpl addImports(JetScope scope) { - WritableScopeImpl writableScope = new WritableScopeImpl(scope, scope.getContainingDeclaration(), RedeclarationHandler.DO_NOTHING); + WritableScopeImpl writableScope = new WritableScopeImpl( + scope, scope.getContainingDeclaration(), RedeclarationHandler.DO_NOTHING, "JetTypeCheckerTest.addImports"); writableScope.importScope(library.getLibraryScope()); InjectorForJavaSemanticServices injector = new InjectorForJavaSemanticServices( myEnvironment.getCompilerDependencies(), getProject()); @@ -694,7 +695,8 @@ public class JetTypeCheckerTest extends JetLiteFixture { trace.record(BindingContext.CLASS, classElement, classDescriptor); - final WritableScope parameterScope = new WritableScopeImpl(scope, classDescriptor, new TraceBasedRedeclarationHandler(trace)); + final WritableScope parameterScope = new WritableScopeImpl( + scope, classDescriptor, new TraceBasedRedeclarationHandler(trace), "JetTypeCheckerTest.resolveClassDescriptor"); parameterScope.changeLockLevel(WritableScope.LockLevel.BOTH); // This call has side-effects on the parameterScope (fills it in) @@ -714,7 +716,8 @@ public class JetTypeCheckerTest extends JetLiteFixture { // } boolean open = classElement.hasModifier(JetTokens.OPEN_KEYWORD); - final WritableScope memberDeclarations = new WritableScopeImpl(JetScope.EMPTY, classDescriptor, new TraceBasedRedeclarationHandler(trace)); + final WritableScope memberDeclarations = new WritableScopeImpl( + JetScope.EMPTY, classDescriptor, new TraceBasedRedeclarationHandler(trace), "JetTypeCheckerTest.resolveClassDescriptor"); memberDeclarations.changeLockLevel(WritableScope.LockLevel.BOTH); List declarations = classElement.getDeclarations();