Dirty candidates do not interfere with clean ones
This commit is contained in:
@@ -656,12 +656,17 @@ public class CallResolver {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
FunctionDescriptor maximallySpecific = findMaximallySpecific(successfulCandidates, traces, false);
|
Map<FunctionDescriptor, FunctionDescriptor> cleanCandidates = Maps.newLinkedHashMap(successfulCandidates);
|
||||||
|
cleanCandidates.keySet().removeAll(dirtyCandidates);
|
||||||
|
if (cleanCandidates.isEmpty()) {
|
||||||
|
cleanCandidates = successfulCandidates;
|
||||||
|
}
|
||||||
|
FunctionDescriptor maximallySpecific = findMaximallySpecific(cleanCandidates, traces, false);
|
||||||
if (maximallySpecific != null) {
|
if (maximallySpecific != null) {
|
||||||
return maximallySpecific;
|
return maximallySpecific;
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionDescriptor maximallySpecificGenericsDiscriminated = findMaximallySpecific(successfulCandidates, traces, true);
|
FunctionDescriptor maximallySpecificGenericsDiscriminated = findMaximallySpecific(cleanCandidates, traces, true);
|
||||||
if (maximallySpecificGenericsDiscriminated != null) {
|
if (maximallySpecificGenericsDiscriminated != null) {
|
||||||
return maximallySpecificGenericsDiscriminated;
|
return maximallySpecificGenericsDiscriminated;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -924,7 +924,7 @@ public class JetTypeInferrer {
|
|||||||
if (value instanceof ErrorValue) {
|
if (value instanceof ErrorValue) {
|
||||||
ErrorValue errorValue = (ErrorValue) value;
|
ErrorValue errorValue = (ErrorValue) value;
|
||||||
context.trace.getErrorHandler().genericError(node, errorValue.getMessage());
|
context.trace.getErrorHandler().genericError(node, errorValue.getMessage());
|
||||||
return null;
|
return getDefaultType(elementType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, value);
|
context.trace.record(BindingContext.COMPILE_TIME_VALUE, expression, value);
|
||||||
@@ -932,6 +932,31 @@ public class JetTypeInferrer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private JetType getDefaultType(IElementType constantType) {
|
||||||
|
if (constantType == JetNodeTypes.INTEGER_CONSTANT) {
|
||||||
|
return semanticServices.getStandardLibrary().getIntType();
|
||||||
|
}
|
||||||
|
else if (constantType == JetNodeTypes.FLOAT_CONSTANT) {
|
||||||
|
return semanticServices.getStandardLibrary().getDoubleType();
|
||||||
|
}
|
||||||
|
else if (constantType == JetNodeTypes.BOOLEAN_CONSTANT) {
|
||||||
|
return semanticServices.getStandardLibrary().getBooleanType();
|
||||||
|
}
|
||||||
|
else if (constantType == JetNodeTypes.CHARACTER_CONSTANT) {
|
||||||
|
return semanticServices.getStandardLibrary().getCharType();
|
||||||
|
}
|
||||||
|
else if (constantType == JetNodeTypes.RAW_STRING_CONSTANT) {
|
||||||
|
return semanticServices.getStandardLibrary().getStringType();
|
||||||
|
}
|
||||||
|
else if (constantType == JetNodeTypes.NULL) {
|
||||||
|
return JetStandardClasses.getNullableNothingType();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw new IllegalArgumentException("Unsupported constant type: " + constantType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetType visitThrowExpression(JetThrowExpression expression, TypeInferenceContext context) {
|
public JetType visitThrowExpression(JetThrowExpression expression, TypeInferenceContext context) {
|
||||||
JetExpression thrownExpression = expression.getThrownExpression();
|
JetExpression thrownExpression = expression.getThrownExpression();
|
||||||
@@ -1216,7 +1241,7 @@ public class JetTypeInferrer {
|
|||||||
// JetScope compositeScope = new ScopeWithReceiver(context.scope, subjectType, semanticServices.getTypeChecker());
|
// JetScope compositeScope = new ScopeWithReceiver(context.scope, subjectType, semanticServices.getTypeChecker());
|
||||||
if (callSuffixExpression != null) {
|
if (callSuffixExpression != null) {
|
||||||
// JetType selectorReturnType = getType(compositeScope, callSuffixExpression, false, context);
|
// JetType selectorReturnType = getType(compositeScope, callSuffixExpression, false, context);
|
||||||
JetType selectorReturnType = getSelectorReturnType(subjectType, callSuffixExpression, context);//getType(compositeScope, callSuffixExpression, false, context);
|
JetType selectorReturnType = getType(subjectType.getMemberScope(), callSuffixExpression, false, context);//getType(compositeScope, callSuffixExpression, false, context);
|
||||||
ensureBooleanResultWithCustomSubject(callSuffixExpression, selectorReturnType, "This expression", context);
|
ensureBooleanResultWithCustomSubject(callSuffixExpression, selectorReturnType, "This expression", context);
|
||||||
context.services.checkNullSafety(subjectType, condition.getOperationTokenNode(), getCalleeFunctionDescriptor(callSuffixExpression, context));
|
context.services.checkNullSafety(subjectType, condition.getOperationTokenNode(), getCalleeFunctionDescriptor(callSuffixExpression, context));
|
||||||
}
|
}
|
||||||
@@ -1771,6 +1796,7 @@ public class JetTypeInferrer {
|
|||||||
JetExpression receiverExpression = expression.getReceiverExpression();
|
JetExpression receiverExpression = expression.getReceiverExpression();
|
||||||
JetType receiverType = context.services.typeInferrerVisitorWithNamespaces.getType(receiverExpression, new TypeInferenceContext(context.trace, context.scope, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE));
|
JetType receiverType = context.services.typeInferrerVisitorWithNamespaces.getType(receiverExpression, new TypeInferenceContext(context.trace, context.scope, false, context.dataFlowInfo, NO_EXPECTED_TYPE, NO_EXPECTED_TYPE));
|
||||||
if (receiverType == null) return null;
|
if (receiverType == null) return null;
|
||||||
|
if (selectorExpression == null) return null;
|
||||||
|
|
||||||
// Clean resolution: no autocasts
|
// Clean resolution: no autocasts
|
||||||
TemporaryBindingTrace cleanResolutionTrace = TemporaryBindingTrace.create(context.trace);
|
TemporaryBindingTrace cleanResolutionTrace = TemporaryBindingTrace.create(context.trace);
|
||||||
|
|||||||
Reference in New Issue
Block a user