diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java index d09e85d2925..fe98653d580 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/CallResolver.java @@ -374,8 +374,8 @@ public class CallResolver { } ConstraintSystem constraintSystemWithoutExpectedTypeConstraint = constraintSystem.copy(); - constraintSystem.addSubtypingConstraint(descriptor.getReturnType(), context.expectedType, - ConstraintPosition.EXPECTED_TYPE_POSITION); + constraintSystem.addSupertypeConstraint(descriptor.getReturnType(), context.expectedType, + ConstraintPosition.EXPECTED_TYPE_POSITION); if (!constraintSystem.isSuccessful()) { @@ -761,8 +761,8 @@ public class CallResolver { ReceiverDescriptor receiverArgument = candidateCall.getReceiverArgument(); ReceiverDescriptor receiverParameter = candidateWithFreshVariables.getReceiverParameter(); if (receiverArgument.exists() && receiverParameter.exists()) { - constraintsSystem.addSupertypeConstraint(receiverParameter.getType(), receiverArgument.getType(), - ConstraintPosition.RECEIVER_POSITION); + constraintsSystem.addSubtypeConstraint(receiverParameter.getType(), receiverArgument.getType(), + ConstraintPosition.RECEIVER_POSITION); } ConstraintSystem constraintSystemWithRightTypeParameters = constraintsSystem.replaceTypeVariables(new Function() { @@ -816,7 +816,7 @@ public class CallResolver { else { type = null; } - constraintSystem.addSupertypeConstraint(effectiveExpectedType, type, ConstraintPosition.getValueParameterPosition( + constraintSystem.addSubtypeConstraint(effectiveExpectedType, type, ConstraintPosition.getValueParameterPosition( valueParameterDescriptor.getIndex())); //todo no return if (isErrorType != null) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystem.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystem.java index c18be884f4e..5d4f3b7d421 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystem.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystem.java @@ -42,22 +42,22 @@ public interface ConstraintSystem { Set getTypeVariables(); /** - * Adds a constraint that the subject type is a supertype of the constraining type.

+ * Adds a constraint that the constraining type is a subtype of the subject type.

* Asserts that only subject type may contain registered type variables.

* * For example, for {@code "fun id(t: T) {}"} to infer T in invocation "id(1)" - * should be generated a constraint "T is a supertype of Int" where T is a subject type, and Int is a constraining type. + * should be generated a constraint "Int is a subtype of T" where T is a subject type, and Int is a constraining type. */ - void addSupertypeConstraint(@NotNull JetType subjectType, @Nullable JetType constrainingType, @NotNull ConstraintPosition constraintPosition); + void addSubtypeConstraint(@NotNull JetType subjectType, @Nullable JetType constrainingType, @NotNull ConstraintPosition constraintPosition); /** - * Adds a constraint that subject type is a subtype of constraining type.

+ * Adds a constraint that the constraining type is a supertype of the subject type.

* Asserts that only subject type may contain registered type variables.

* * For example, for {@code "fun create() : T"} to infer T in invocation "val i: Int = create()" - * should be generated a constraint "T is a subtype of Int" where T is a subject type, and Int is a constraining type. + * should be generated a constraint "Int is a supertype of T" where T is a subject type, and Int is a constraining type. */ - void addSubtypingConstraint(@NotNull JetType subjectType, @Nullable JetType constrainingType, @NotNull ConstraintPosition constraintPosition); + void addSupertypeConstraint(@NotNull JetType subjectType, @Nullable JetType constrainingType, @NotNull ConstraintPosition constraintPosition); /** * Returns true if constraint system has a solution (has no contradiction and has enough information to infer each registered type variable). diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java index 566ee6628ba..bbf04dcdc91 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/inference/ConstraintSystemImpl.java @@ -141,12 +141,20 @@ public class ConstraintSystemImpl implements ConstraintSystem { } @Override - public void addSubtypingConstraint(@NotNull JetType subjectType, @Nullable JetType constrainingType, @NotNull ConstraintPosition constraintPosition) { + public void addSupertypeConstraint( + @NotNull JetType subjectType, + @Nullable JetType constrainingType, + @NotNull ConstraintPosition constraintPosition + ) { addConstraint(SUB_TYPE, subjectType, constrainingType, constraintPosition); } @Override - public void addSupertypeConstraint(@NotNull JetType subjectType, @Nullable JetType constrainingType, @NotNull ConstraintPosition constraintPosition) { + public void addSubtypeConstraint( + @NotNull JetType subjectType, + @Nullable JetType constrainingType, + @NotNull ConstraintPosition constraintPosition + ) { addConstraint(SUPER_TYPE, subjectType, constrainingType, constraintPosition); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java index 1b58a1f1093..c149916d330 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java @@ -252,7 +252,7 @@ public class ExpressionTypingUtils { } } - constraintSystem.addSupertypeConstraint(callReceiver.getType(), receiverType, ConstraintPosition.RECEIVER_POSITION); + constraintSystem.addSubtypeConstraint(callReceiver.getType(), receiverType, ConstraintPosition.RECEIVER_POSITION); return constraintSystem.isSuccessful() && ConstraintsUtil.checkBoundsAreSatisfied(constraintSystem); }