isVariableReassignment
This commit is contained in:
@@ -41,6 +41,8 @@ public interface BindingContext {
|
||||
boolean isStatement(JetExpression expression);
|
||||
boolean hasBackingField(PropertyDescriptor propertyDescriptor);
|
||||
|
||||
boolean isVariableReassignment(JetBinaryExpression expression);
|
||||
|
||||
ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall);
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -29,6 +29,8 @@ public interface BindingTrace {
|
||||
|
||||
void recordStatement(@NotNull JetElement statement);
|
||||
|
||||
void recordVariableReassignment(@NotNull JetBinaryExpression expression);
|
||||
|
||||
void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope);
|
||||
|
||||
void removeStatementRecord(@NotNull JetElement statement);
|
||||
|
||||
@@ -57,6 +57,11 @@ public class BindingTraceAdapter implements BindingTrace {
|
||||
originalTrace.recordStatement(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordVariableReassignment(@NotNull JetBinaryExpression expression) {
|
||||
originalTrace.recordVariableReassignment(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void requireBackingField(@NotNull PropertyDescriptor propertyDescriptor) {
|
||||
originalTrace.requireBackingField(propertyDescriptor);
|
||||
|
||||
@@ -31,6 +31,8 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
|
||||
private final Map<JetExpression, JetType> autoCasts = Maps.newHashMap();
|
||||
private final Map<JetExpression, JetScope> resolutionScopes = Maps.newHashMap();
|
||||
|
||||
private final Set<JetBinaryExpression> variableReassignments = Sets.newHashSet();
|
||||
|
||||
private final Set<JetFunctionLiteralExpression> blocks = new HashSet<JetFunctionLiteralExpression>();
|
||||
private final Set<JetElement> statements = new HashSet<JetElement>();
|
||||
private final Set<PropertyDescriptor> backingFieldRequired = new HashSet<PropertyDescriptor>();
|
||||
@@ -61,6 +63,8 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
|
||||
backingFieldRequired.addAll(other.backingFieldRequired);
|
||||
processed.addAll(other.processed);
|
||||
|
||||
variableReassignments.addAll(other.variableReassignments);
|
||||
|
||||
diagnostics.addAll(other.diagnostics);
|
||||
}
|
||||
|
||||
@@ -158,6 +162,11 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
|
||||
statements.add(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordVariableReassignment(@NotNull JetBinaryExpression expression) {
|
||||
variableReassignments.add(expression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope) {
|
||||
safePut(resolutionScopes, expression, scope);
|
||||
@@ -298,6 +307,11 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
|
||||
return backingFieldRequired.contains(propertyDescriptor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVariableReassignment(JetBinaryExpression expression) {
|
||||
return variableReassignments.contains(expression);
|
||||
}
|
||||
|
||||
public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) {
|
||||
JetTypeReference typeReference = superCall.getTypeReference();
|
||||
if (typeReference == null) return null;
|
||||
|
||||
@@ -2587,7 +2587,10 @@ public class JetTypeInferrer {
|
||||
|
||||
if (assignmentOperationType == null) {
|
||||
String counterpartName = binaryOperationNames.get(assignmentOperationCounterparts.get(operationType));
|
||||
getTypeForBinaryCall(expression, counterpartName, scope, true);
|
||||
JetType typeForBinaryCall = getTypeForBinaryCall(expression, counterpartName, scope, true);
|
||||
if (typeForBinaryCall != null) {
|
||||
context.trace.recordVariableReassignment(expression);
|
||||
}
|
||||
}
|
||||
result = null; // not an expression
|
||||
}
|
||||
|
||||
@@ -53,6 +53,11 @@ public class JetTestUtils {
|
||||
public void recordStatement(@NotNull JetElement statement) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordVariableReassignment(@NotNull JetBinaryExpression expression) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope) {
|
||||
}
|
||||
@@ -185,6 +190,11 @@ public class JetTestUtils {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVariableReassignment(JetBinaryExpression expression) {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall) {
|
||||
throw new UnsupportedOperationException(); // TODO
|
||||
|
||||
Reference in New Issue
Block a user