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) {
|
||||
boolean result = true;
|
||||
for (Map.Entry<ValueArgument, ValueParameterDescriptor> entry : argumentsToParameters.entrySet()) {
|
||||
ValueArgument valueArgument = entry.getKey();
|
||||
ValueParameterDescriptor valueParameterDescriptor = entry.getValue();
|
||||
@@ -536,11 +537,11 @@ public class CallResolver {
|
||||
dirty.setValue(true);
|
||||
}
|
||||
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) {
|
||||
|
||||
@@ -658,6 +658,15 @@ public class JetTypeInferrer {
|
||||
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
|
||||
public final JetType getType(@NotNull JetExpression expression, TypeInferenceContext context) {
|
||||
if (context.trace.get(BindingContext.PROCESSED, expression)) {
|
||||
@@ -2115,9 +2124,9 @@ public class JetTypeInferrer {
|
||||
@Override
|
||||
public JetType visitIsExpression(JetIsExpression expression, TypeInferenceContext contextWithExpectedType) {
|
||||
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();
|
||||
if (pattern != null && knownType != null) {
|
||||
if (pattern != null) {
|
||||
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));
|
||||
patternsToDataFlowInfo.put(pattern, newDataFlowInfo);
|
||||
@@ -2218,10 +2227,7 @@ public class JetTypeInferrer {
|
||||
else if (equalsOperations.contains(operationType)) {
|
||||
String name = "equals";
|
||||
if (right != null) {
|
||||
JetType leftType = getType(left, context.replaceScope(context.scope));
|
||||
if (leftType == null) {
|
||||
leftType = ErrorUtils.createErrorType("No type for " + left.getText());
|
||||
}
|
||||
JetType leftType = safeGetType(left, context.replaceScope(context.scope));
|
||||
OverloadResolutionResult<FunctionDescriptor> resolutionResult = context.services.callResolver.resolveExactSignature(
|
||||
context.scope, leftType, "equals",
|
||||
Collections.singletonList(JetStandardClasses.getNullableAnyType()));
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package variance
|
||||
namespace variance
|
||||
|
||||
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 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<error>(ints, numbers)</error>
|
||||
copy2(ints, <error>numbers</error>)
|
||||
copy3<Int>(ints, numbers)
|
||||
copy4(ints, numbers) //ok
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user