addition to bug with automatically casting mutable variables fix
This commit is contained in:
@@ -853,10 +853,18 @@ public class JetTypeInferrer {
|
|||||||
if (!semanticServices.getTypeChecker().isSubtypeOf(enrichedType, context.expectedType)) {
|
if (!semanticServices.getTypeChecker().isSubtypeOf(enrichedType, context.expectedType)) {
|
||||||
context.trace.getErrorHandler().typeMismatch(expression, context.expectedType, expressionType);
|
context.trace.getErrorHandler().typeMismatch(expression, context.expectedType, expressionType);
|
||||||
} else {
|
} else {
|
||||||
context.trace.record(BindingContext.AUTOCAST, expression, context.expectedType);
|
checkAutoCast(expression, context.expectedType, variableDescriptor, context.trace);
|
||||||
}
|
}
|
||||||
return enrichedType;
|
return enrichedType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkAutoCast(JetExpression expression, JetType type, VariableDescriptor variableDescriptor, BindingTrace trace) {
|
||||||
|
if (variableDescriptor.isVar()) {
|
||||||
|
trace.getErrorHandler().genericError(expression.getNode(), "Automatic cast to " + type + " is impossible, because variable " + variableDescriptor.getName() + " is mutable");
|
||||||
|
} else {
|
||||||
|
trace.record(BindingContext.AUTOCAST, expression, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private List<JetType> checkArgumentTypes(@NotNull List<JetType> argumentTypes, @NotNull List<JetExpression> arguments, @NotNull List<TypeProjection> expectedArgumentTypes, @NotNull TypeInferenceContext context) {
|
private List<JetType> checkArgumentTypes(@NotNull List<JetType> argumentTypes, @NotNull List<JetExpression> arguments, @NotNull List<TypeProjection> expectedArgumentTypes, @NotNull TypeInferenceContext context) {
|
||||||
@@ -2202,7 +2210,7 @@ public class JetTypeInferrer {
|
|||||||
for (JetType possibleType : possibleTypes) {
|
for (JetType possibleType : possibleTypes) {
|
||||||
selectorReturnType = getSelectorReturnType(possibleType, selectorExpression, autocastResolutionContext);
|
selectorReturnType = getSelectorReturnType(possibleType, selectorExpression, autocastResolutionContext);
|
||||||
if (selectorReturnType != null) {
|
if (selectorReturnType != null) {
|
||||||
autocastResolutionTrace.record(BindingContext.AUTOCAST, receiverExpression, possibleType);
|
context.services.checkAutoCast(receiverExpression, possibleType, variableDescriptor, autocastResolutionTrace);
|
||||||
autocastResolutionTrace.addAllMyDataTo(context.trace);
|
autocastResolutionTrace.addAllMyDataTo(context.trace);
|
||||||
somethingFound = true;
|
somethingFound = true;
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user