refactoring: changed the order of the parameters
This commit is contained in:
@@ -220,7 +220,7 @@ public class CandidateResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ConstraintSystem constraintSystemWithoutExpectedTypeConstraint = constraintSystem.copy();
|
ConstraintSystem constraintSystemWithoutExpectedTypeConstraint = constraintSystem.copy();
|
||||||
constraintSystem.addSupertypeConstraint(descriptor.getReturnType(), context.expectedType,
|
constraintSystem.addSupertypeConstraint(context.expectedType, descriptor.getReturnType(),
|
||||||
ConstraintPosition.EXPECTED_TYPE_POSITION);
|
ConstraintPosition.EXPECTED_TYPE_POSITION);
|
||||||
|
|
||||||
|
|
||||||
@@ -303,7 +303,7 @@ public class CandidateResolver {
|
|||||||
context.candidateCall.isSafeCall()
|
context.candidateCall.isSafeCall()
|
||||||
? TypeUtils.makeNotNullable(receiverArgument.getType())
|
? TypeUtils.makeNotNullable(receiverArgument.getType())
|
||||||
: receiverArgument.getType();
|
: receiverArgument.getType();
|
||||||
constraintSystem.addSubtypeConstraint(receiverParameter.getType(), receiverType, ConstraintPosition.RECEIVER_POSITION);
|
constraintSystem.addSubtypeConstraint(receiverType, receiverParameter.getType(), ConstraintPosition.RECEIVER_POSITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstraintSystem
|
ConstraintSystem
|
||||||
@@ -355,7 +355,7 @@ public class CandidateResolver {
|
|||||||
JetType expectedType = substitutor.substitute(effectiveExpectedType, Variance.INVARIANT);
|
JetType expectedType = substitutor.substitute(effectiveExpectedType, Variance.INVARIANT);
|
||||||
JetType type = argumentTypeResolver.getArgumentTypeInfo(argumentExpression, traceForUnknown, context.scope, context.dataFlowInfo,
|
JetType type = argumentTypeResolver.getArgumentTypeInfo(argumentExpression, traceForUnknown, context.scope, context.dataFlowInfo,
|
||||||
expectedType != null ? expectedType : NO_EXPECTED_TYPE, resolveFunctionArgumentBodies).getType();
|
expectedType != null ? expectedType : NO_EXPECTED_TYPE, resolveFunctionArgumentBodies).getType();
|
||||||
constraintSystem.addSubtypeConstraint(effectiveExpectedType, type, ConstraintPosition.getValueParameterPosition(
|
constraintSystem.addSubtypeConstraint(type, effectiveExpectedType, ConstraintPosition.getValueParameterPosition(
|
||||||
valueParameterDescriptor.getIndex()));
|
valueParameterDescriptor.getIndex()));
|
||||||
if (isErrorType != null) {
|
if (isErrorType != null) {
|
||||||
isErrorType[0] = type == null || ErrorUtils.isErrorType(type);
|
isErrorType[0] = type == null || ErrorUtils.isErrorType(type);
|
||||||
|
|||||||
+2
-2
@@ -45,7 +45,7 @@ public interface ConstraintSystem {
|
|||||||
* For example, for {@code "fun <T> id(t: T) {}"} to infer <tt>T</tt> in invocation <tt>"id(1)"</tt>
|
* For example, for {@code "fun <T> id(t: T) {}"} to infer <tt>T</tt> in invocation <tt>"id(1)"</tt>
|
||||||
* should be generated a constraint <tt>"Int is a subtype of T"</tt> where T is a subject type, and Int is a constraining type.
|
* should be generated a constraint <tt>"Int is a subtype of T"</tt> where T is a subject type, and Int is a constraining type.
|
||||||
*/
|
*/
|
||||||
void addSubtypeConstraint(@NotNull JetType subjectType, @Nullable JetType constrainingType, @NotNull ConstraintPosition constraintPosition);
|
void addSubtypeConstraint(@Nullable JetType constrainingType, @NotNull JetType subjectType, @NotNull ConstraintPosition constraintPosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a constraint that the constraining type is a supertype of the subject type. <p/>
|
* Adds a constraint that the constraining type is a supertype of the subject type. <p/>
|
||||||
@@ -54,7 +54,7 @@ public interface ConstraintSystem {
|
|||||||
* For example, for {@code "fun <T> create() : T"} to infer <tt>T</tt> in invocation <tt>"val i: Int = create()"</tt>
|
* For example, for {@code "fun <T> create() : T"} to infer <tt>T</tt> in invocation <tt>"val i: Int = create()"</tt>
|
||||||
* should be generated a constraint <tt>"Int is a supertype of T"</tt> where T is a subject type, and Int is a constraining type.
|
* should be generated a constraint <tt>"Int is a supertype of T"</tt> where T is a subject type, and Int is a constraining type.
|
||||||
*/
|
*/
|
||||||
void addSupertypeConstraint(@NotNull JetType subjectType, @Nullable JetType constrainingType, @NotNull ConstraintPosition constraintPosition);
|
void addSupertypeConstraint(@Nullable JetType constrainingType, @NotNull JetType subjectType, @NotNull ConstraintPosition constraintPosition);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns <tt>true</tt> if constraint system has a solution (has no contradiction and has enough information to infer each registered type variable).
|
* Returns <tt>true</tt> if constraint system has a solution (has no contradiction and has enough information to infer each registered type variable).
|
||||||
|
|||||||
+2
-2
@@ -140,8 +140,8 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSupertypeConstraint(
|
public void addSupertypeConstraint(
|
||||||
@NotNull JetType subjectType,
|
|
||||||
@Nullable JetType constrainingType,
|
@Nullable JetType constrainingType,
|
||||||
|
@NotNull JetType subjectType,
|
||||||
@NotNull ConstraintPosition constraintPosition
|
@NotNull ConstraintPosition constraintPosition
|
||||||
) {
|
) {
|
||||||
addConstraint(SUPER_TYPE, subjectType, constrainingType, constraintPosition);
|
addConstraint(SUPER_TYPE, subjectType, constrainingType, constraintPosition);
|
||||||
@@ -149,8 +149,8 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addSubtypeConstraint(
|
public void addSubtypeConstraint(
|
||||||
@NotNull JetType subjectType,
|
|
||||||
@Nullable JetType constrainingType,
|
@Nullable JetType constrainingType,
|
||||||
|
@NotNull JetType subjectType,
|
||||||
@NotNull ConstraintPosition constraintPosition
|
@NotNull ConstraintPosition constraintPosition
|
||||||
) {
|
) {
|
||||||
addConstraint(SUB_TYPE, subjectType, constrainingType, constraintPosition);
|
addConstraint(SUB_TYPE, subjectType, constrainingType, constraintPosition);
|
||||||
|
|||||||
+1
-1
@@ -250,7 +250,7 @@ public class ExpressionTypingUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
constraintSystem.addSubtypeConstraint(receiverParameter.getType(), receiverType, ConstraintPosition.RECEIVER_POSITION);
|
constraintSystem.addSubtypeConstraint(receiverType, receiverParameter.getType(), ConstraintPosition.RECEIVER_POSITION);
|
||||||
return constraintSystem.isSuccessful() && ConstraintsUtil.checkBoundsAreSatisfied(constraintSystem);
|
return constraintSystem.isSuccessful() && ConstraintsUtil.checkBoundsAreSatisfied(constraintSystem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user