isVariableReassignment for ++ and --
This commit is contained in:
@@ -41,7 +41,7 @@ public interface BindingContext {
|
|||||||
boolean isStatement(JetExpression expression);
|
boolean isStatement(JetExpression expression);
|
||||||
boolean hasBackingField(PropertyDescriptor propertyDescriptor);
|
boolean hasBackingField(PropertyDescriptor propertyDescriptor);
|
||||||
|
|
||||||
boolean isVariableReassignment(JetBinaryExpression expression);
|
boolean isVariableReassignment(JetExpression expression);
|
||||||
|
|
||||||
ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall);
|
ConstructorDescriptor resolveSuperConstructor(JetDelegatorToSuperCall superCall);
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public interface BindingTrace {
|
|||||||
|
|
||||||
void recordStatement(@NotNull JetElement statement);
|
void recordStatement(@NotNull JetElement statement);
|
||||||
|
|
||||||
void recordVariableReassignment(@NotNull JetBinaryExpression expression);
|
void recordVariableReassignment(@NotNull JetExpression expression);
|
||||||
|
|
||||||
void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope);
|
void recordResolutionScope(@NotNull JetExpression expression, @NotNull JetScope scope);
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class BindingTraceAdapter implements BindingTrace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordVariableReassignment(@NotNull JetBinaryExpression expression) {
|
public void recordVariableReassignment(@NotNull JetExpression expression) {
|
||||||
originalTrace.recordVariableReassignment(expression);
|
originalTrace.recordVariableReassignment(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
|
|||||||
private final Map<JetExpression, JetType> autoCasts = Maps.newHashMap();
|
private final Map<JetExpression, JetType> autoCasts = Maps.newHashMap();
|
||||||
private final Map<JetExpression, JetScope> resolutionScopes = Maps.newHashMap();
|
private final Map<JetExpression, JetScope> resolutionScopes = Maps.newHashMap();
|
||||||
|
|
||||||
private final Set<JetBinaryExpression> variableReassignments = Sets.newHashSet();
|
private final Set<JetExpression> variableReassignments = Sets.newHashSet();
|
||||||
|
|
||||||
private final Set<JetFunctionLiteralExpression> blocks = new HashSet<JetFunctionLiteralExpression>();
|
private final Set<JetFunctionLiteralExpression> blocks = new HashSet<JetFunctionLiteralExpression>();
|
||||||
private final Set<JetElement> statements = new HashSet<JetElement>();
|
private final Set<JetElement> statements = new HashSet<JetElement>();
|
||||||
@@ -163,7 +163,7 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordVariableReassignment(@NotNull JetBinaryExpression expression) {
|
public void recordVariableReassignment(@NotNull JetExpression expression) {
|
||||||
variableReassignments.add(expression);
|
variableReassignments.add(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -308,7 +308,7 @@ public class BindingTraceContext implements BindingContext, BindingTrace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVariableReassignment(JetBinaryExpression expression) {
|
public boolean isVariableReassignment(JetExpression expression) {
|
||||||
return variableReassignments.contains(expression);
|
return variableReassignments.contains(expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2167,12 +2167,15 @@ public class JetTypeInferrer {
|
|||||||
JetType returnType = functionDescriptor.getReturnType();
|
JetType returnType = functionDescriptor.getReturnType();
|
||||||
if (operationType == JetTokens.PLUSPLUS || operationType == JetTokens.MINUSMINUS) {
|
if (operationType == JetTokens.PLUSPLUS || operationType == JetTokens.MINUSMINUS) {
|
||||||
if (semanticServices.getTypeChecker().isSubtypeOf(returnType, JetStandardClasses.getUnitType())) {
|
if (semanticServices.getTypeChecker().isSubtypeOf(returnType, JetStandardClasses.getUnitType())) {
|
||||||
result = JetStandardClasses.getUnitType();
|
result = JetStandardClasses.getUnitType();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!semanticServices.getTypeChecker().isSubtypeOf(returnType, receiverType)) {
|
if (!semanticServices.getTypeChecker().isSubtypeOf(returnType, receiverType)) {
|
||||||
context.trace.getErrorHandler().genericError(operationSign.getNode(), name + " must return " + receiverType + " but returns " + returnType);
|
context.trace.getErrorHandler().genericError(operationSign.getNode(), name + " must return " + receiverType + " but returns " + returnType);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
context.trace.recordVariableReassignment(expression);
|
||||||
|
}
|
||||||
// TODO : Maybe returnType?
|
// TODO : Maybe returnType?
|
||||||
result = receiverType;
|
result = receiverType;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class JetTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void recordVariableReassignment(@NotNull JetBinaryExpression expression) {
|
public void recordVariableReassignment(@NotNull JetExpression expression) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,7 +191,7 @@ public class JetTestUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isVariableReassignment(JetBinaryExpression expression) {
|
public boolean isVariableReassignment(JetExpression expression) {
|
||||||
throw new UnsupportedOperationException(); // TODO
|
throw new UnsupportedOperationException(); // TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user