Two tests fixed
This commit is contained in:
@@ -520,6 +520,7 @@ public class CallResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkValueArgumentTypes(JetScope scope, JetTypeInferrer.Services temporaryServices, Map<ValueArgument, ValueParameterDescriptor> argumentsToParameters, Flag dirty, Function<ValueParameterDescriptor, ValueParameterDescriptor> parameterMap) {
|
private boolean checkValueArgumentTypes(JetScope scope, JetTypeInferrer.Services temporaryServices, Map<ValueArgument, ValueParameterDescriptor> argumentsToParameters, Flag dirty, Function<ValueParameterDescriptor, ValueParameterDescriptor> parameterMap) {
|
||||||
|
boolean result = true;
|
||||||
for (Map.Entry<ValueArgument, ValueParameterDescriptor> entry : argumentsToParameters.entrySet()) {
|
for (Map.Entry<ValueArgument, ValueParameterDescriptor> entry : argumentsToParameters.entrySet()) {
|
||||||
ValueArgument valueArgument = entry.getKey();
|
ValueArgument valueArgument = entry.getKey();
|
||||||
ValueParameterDescriptor valueParameterDescriptor = entry.getValue();
|
ValueParameterDescriptor valueParameterDescriptor = entry.getValue();
|
||||||
@@ -536,11 +537,11 @@ public class CallResolver {
|
|||||||
dirty.setValue(true);
|
dirty.setValue(true);
|
||||||
}
|
}
|
||||||
else if (!semanticServices.getTypeChecker().isSubtypeOf(type, parameterType)) {
|
else if (!semanticServices.getTypeChecker().isSubtypeOf(type, parameterType)) {
|
||||||
return false;
|
result = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkGenericBoundsInAFunctionCall(List<JetTypeProjection> jetTypeArguments, List<JetType> typeArguments, CallableDescriptor functionDescriptor) {
|
public void checkGenericBoundsInAFunctionCall(List<JetTypeProjection> jetTypeArguments, List<JetType> typeArguments, CallableDescriptor functionDescriptor) {
|
||||||
|
|||||||
@@ -658,6 +658,15 @@ public class JetTypeInferrer {
|
|||||||
return resultDataFlowInfo;
|
return resultDataFlowInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public final JetType safeGetType(@NotNull JetExpression expression, TypeInferenceContext context) {
|
||||||
|
JetType type = getType(expression, context);
|
||||||
|
if (type != null) {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
return ErrorUtils.createErrorType("Type for " + expression.getText());
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public final JetType getType(@NotNull JetExpression expression, TypeInferenceContext context) {
|
public final JetType getType(@NotNull JetExpression expression, TypeInferenceContext context) {
|
||||||
if (context.trace.get(BindingContext.PROCESSED, expression)) {
|
if (context.trace.get(BindingContext.PROCESSED, expression)) {
|
||||||
@@ -2115,9 +2124,9 @@ public class JetTypeInferrer {
|
|||||||
@Override
|
@Override
|
||||||
public JetType visitIsExpression(JetIsExpression expression, TypeInferenceContext contextWithExpectedType) {
|
public JetType visitIsExpression(JetIsExpression expression, TypeInferenceContext contextWithExpectedType) {
|
||||||
TypeInferenceContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE);
|
TypeInferenceContext context = contextWithExpectedType.replaceExpectedType(NO_EXPECTED_TYPE);
|
||||||
JetType knownType = getType(expression.getLeftHandSide(), context.replaceScope(context.scope));
|
JetType knownType = safeGetType(expression.getLeftHandSide(), context.replaceScope(context.scope));
|
||||||
JetPattern pattern = expression.getPattern();
|
JetPattern pattern = expression.getPattern();
|
||||||
if (pattern != null && knownType != null) {
|
if (pattern != null) {
|
||||||
WritableScopeImpl scopeToExtend = newWritableScopeImpl(context.scope, context.trace).setDebugName("Scope extended in 'is'");
|
WritableScopeImpl scopeToExtend = newWritableScopeImpl(context.scope, context.trace).setDebugName("Scope extended in 'is'");
|
||||||
DataFlowInfo newDataFlowInfo = checkPatternType(pattern, knownType, scopeToExtend, context, context.services.getVariableDescriptorFromSimpleName(expression.getLeftHandSide(), context));
|
DataFlowInfo newDataFlowInfo = checkPatternType(pattern, knownType, scopeToExtend, context, context.services.getVariableDescriptorFromSimpleName(expression.getLeftHandSide(), context));
|
||||||
patternsToDataFlowInfo.put(pattern, newDataFlowInfo);
|
patternsToDataFlowInfo.put(pattern, newDataFlowInfo);
|
||||||
@@ -2218,10 +2227,7 @@ public class JetTypeInferrer {
|
|||||||
else if (equalsOperations.contains(operationType)) {
|
else if (equalsOperations.contains(operationType)) {
|
||||||
String name = "equals";
|
String name = "equals";
|
||||||
if (right != null) {
|
if (right != null) {
|
||||||
JetType leftType = getType(left, context.replaceScope(context.scope));
|
JetType leftType = safeGetType(left, context.replaceScope(context.scope));
|
||||||
if (leftType == null) {
|
|
||||||
leftType = ErrorUtils.createErrorType("No type for " + left.getText());
|
|
||||||
}
|
|
||||||
OverloadResolutionResult<FunctionDescriptor> resolutionResult = context.services.callResolver.resolveExactSignature(
|
OverloadResolutionResult<FunctionDescriptor> resolutionResult = context.services.callResolver.resolveExactSignature(
|
||||||
context.scope, leftType, "equals",
|
context.scope, leftType, "equals",
|
||||||
Collections.singletonList(JetStandardClasses.getNullableAnyType()));
|
Collections.singletonList(JetStandardClasses.getNullableAnyType()));
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package variance
|
namespace variance
|
||||||
|
|
||||||
abstract class Consumer<in T> {}
|
abstract class Consumer<in T> {}
|
||||||
|
|
||||||
@@ -32,9 +32,9 @@ fun <T> copy3(from : Array<out T>, to : Array<in T>) {}
|
|||||||
fun copy4(from : Array<out Number>, to : Array<in Int>) {}
|
fun copy4(from : Array<out Number>, to : Array<in Int>) {}
|
||||||
|
|
||||||
fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) {
|
fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) {
|
||||||
copy1<error>(ints, any)</error>
|
copy1(<error>ints</error>, any)
|
||||||
copy2(ints, any) //ok
|
copy2(ints, any) //ok
|
||||||
copy2<error>(ints, numbers)</error>
|
copy2(ints, <error>numbers</error>)
|
||||||
copy3<Int>(ints, numbers)
|
copy3<Int>(ints, numbers)
|
||||||
copy4(ints, numbers) //ok
|
copy4(ints, numbers) //ok
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user