WritableScopeImpl: specify debug name in constructor
This commit is contained in:
+1
-1
@@ -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);
|
||||
|
||||
+6
-7
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<TypeParameterDescriptorImpl> typeParameterDescriptors = resolveTypeParameters(functionDescriptor, innerScope, function.getTypeParameters(), trace);
|
||||
@@ -586,7 +586,8 @@ public class DescriptorResolver {
|
||||
|
||||
public JetScope getPropertyDeclarationInnerScope(@NotNull JetScope outerScope, @NotNull List<? extends TypeParameterDescriptor> 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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -276,7 +276,7 @@ public class TopDownAnalyzer {
|
||||
@NotNull List<AnalyzerScriptParameter> 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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+5
-11
@@ -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<JetScope> 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<JetScope> 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;
|
||||
|
||||
@@ -36,8 +36,9 @@ public class WriteThroughScope extends WritableScopeWithImports {
|
||||
private final WritableScope writableWorker;
|
||||
private Collection<DeclarationDescriptor> 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;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -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));
|
||||
|
||||
+7
-7
@@ -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<JetElement> 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) {
|
||||
|
||||
+2
-1
@@ -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);
|
||||
}
|
||||
|
||||
+3
-2
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ public class ExpressionTypingVisitorDispatcher extends JetVisitor<JetType, Expre
|
||||
}
|
||||
|
||||
private ExpressionTypingVisitorForStatements createStatementVisitor(ExpressionTypingContext context) {
|
||||
return new ExpressionTypingVisitorForStatements(this, ExpressionTypingUtils.newWritableScopeImpl(context).setDebugName("statement scope"), basic, controlStructures, patterns);
|
||||
return new ExpressionTypingVisitorForStatements(this, ExpressionTypingUtils.newWritableScopeImpl(context, "statement scope"), basic, controlStructures, patterns);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-4
@@ -58,7 +58,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
JetType knownType = facade.safeGetType(leftHandSide, context.replaceScope(context.scope));
|
||||
JetPattern pattern = expression.getPattern();
|
||||
if (pattern != null) {
|
||||
WritableScopeImpl scopeToExtend = newWritableScopeImpl(context).setDebugName("Scope extended in 'is'");
|
||||
WritableScopeImpl scopeToExtend = newWritableScopeImpl(context, "Scope extended in 'is'");
|
||||
DataFlowValue dataFlowValue = DataFlowValueFactory.INSTANCE.createDataFlowValue(leftHandSide, knownType, context.trace.getBindingContext());
|
||||
DataFlowInfo newDataFlowInfo = checkPatternType(pattern, knownType, false, scopeToExtend, context, dataFlowValue);
|
||||
context.patternsToDataFlowInfo.put(pattern, newDataFlowInfo);
|
||||
@@ -90,7 +90,7 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
DataFlowInfo newDataFlowInfo;
|
||||
WritableScope scopeToExtend;
|
||||
if (conditions.length == 1) {
|
||||
scopeToExtend = newWritableScopeImpl(context).setDebugName("Scope extended in when entry");
|
||||
scopeToExtend = newWritableScopeImpl(context, "Scope extended in when entry");
|
||||
newDataFlowInfo = context.dataFlowInfo;
|
||||
JetWhenCondition condition = conditions[0];
|
||||
if (condition != null) {
|
||||
@@ -98,10 +98,12 @@ public class PatternMatchingTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
}
|
||||
else {
|
||||
scopeToExtend = newWritableScopeImpl(context); // We don't write to this scope
|
||||
scopeToExtend = newWritableScopeImpl(context, "pattern matching"); // We don't write to this scope
|
||||
newDataFlowInfo = null;
|
||||
for (JetWhenCondition condition : conditions) {
|
||||
DataFlowInfo dataFlowInfo = checkWhenCondition(subjectExpression, subjectExpression == null, subjectType, condition, newWritableScopeImpl(context), context, variableDescriptor);
|
||||
DataFlowInfo dataFlowInfo = checkWhenCondition(
|
||||
subjectExpression, subjectExpression == null, subjectType, condition,
|
||||
newWritableScopeImpl(context, ""), context, variableDescriptor);
|
||||
if (newDataFlowInfo == null) {
|
||||
newDataFlowInfo = dataFlowInfo;
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ public class JetStandardClasses {
|
||||
STANDARD_CLASSES_NAMESPACE,
|
||||
Collections.<AnnotationDescriptor>emptyList(),
|
||||
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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -70,7 +70,8 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
Collections.<AnalyzerScriptParameter>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);
|
||||
|
||||
@@ -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<JetDeclaration> declarations = classElement.getDeclarations();
|
||||
|
||||
Reference in New Issue
Block a user