Rename: TypeCheckerTypingConstraints -> TypeCheckerProcedureCallbacks

This commit is contained in:
Svetlana Isakova
2014-12-12 16:41:51 +03:00
parent 239b9a96a0
commit a589323eaf
5 changed files with 13 additions and 13 deletions
@@ -28,7 +28,7 @@ import org.jetbrains.jet.lang.types.Variance
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns
import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind import org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind
import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedure import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedure
import org.jetbrains.jet.lang.types.checker.TypingConstraints import org.jetbrains.jet.lang.types.checker.TypeCheckingProcedureCallbacks
import org.jetbrains.jet.lang.types.TypeConstructor import org.jetbrains.jet.lang.types.TypeConstructor
import java.util.LinkedHashMap import java.util.LinkedHashMap
import java.util.HashSet import java.util.HashSet
@@ -214,7 +214,7 @@ public class ConstraintSystemImpl : ConstraintSystem {
} }
private fun addConstraint(constraintKind: ConstraintKind, subType: JetType?, superType: JetType?, constraintPosition: ConstraintPosition) { private fun addConstraint(constraintKind: ConstraintKind, subType: JetType?, superType: JetType?, constraintPosition: ConstraintPosition) {
val typeCheckingProcedure = TypeCheckingProcedure(object : TypingConstraints { val typeCheckingProcedure = TypeCheckingProcedure(object : TypeCheckingProcedureCallbacks {
private var isTopLevel = true private var isTopLevel = true
override fun assertEqualTypes(a: JetType, b: JetType, typeCheckingProcedure: TypeCheckingProcedure): Boolean { override fun assertEqualTypes(a: JetType, b: JetType, typeCheckingProcedure: TypeCheckingProcedure): Boolean {
@@ -26,9 +26,9 @@ public class JetTypeChecker {
boolean equals(@NotNull TypeConstructor a, @NotNull TypeConstructor b); boolean equals(@NotNull TypeConstructor a, @NotNull TypeConstructor b);
} }
public static final JetTypeChecker DEFAULT = new JetTypeChecker(new TypeCheckingProcedure(new TypeCheckerTypingConstraints())); public static final JetTypeChecker DEFAULT = new JetTypeChecker(new TypeCheckingProcedure(new TypeCheckerProcedureCallbacksImpl()));
public static final JetTypeChecker FLEXIBLE_UNEQUAL_TO_INFLEXIBLE = new JetTypeChecker(new TypeCheckingProcedure(new TypeCheckerTypingConstraints()) { public static final JetTypeChecker FLEXIBLE_UNEQUAL_TO_INFLEXIBLE = new JetTypeChecker(new TypeCheckingProcedure(new TypeCheckerProcedureCallbacksImpl()) {
@Override @Override
protected boolean heterogeneousEquivalence(JetType inflexibleType, JetType flexibleType) { protected boolean heterogeneousEquivalence(JetType inflexibleType, JetType flexibleType) {
return false; return false;
@@ -37,7 +37,7 @@ public class JetTypeChecker {
@NotNull @NotNull
public static JetTypeChecker withAxioms(@NotNull final TypeConstructorEquality equalityAxioms) { public static JetTypeChecker withAxioms(@NotNull final TypeConstructorEquality equalityAxioms) {
return new JetTypeChecker(new TypeCheckingProcedure(new TypeCheckerTypingConstraints() { return new JetTypeChecker(new TypeCheckingProcedure(new TypeCheckerProcedureCallbacksImpl() {
@Override @Override
public boolean assertEqualTypeConstructors(@NotNull TypeConstructor constructor1, @NotNull TypeConstructor constructor2) { public boolean assertEqualTypeConstructors(@NotNull TypeConstructor constructor1, @NotNull TypeConstructor constructor2) {
return constructor1.equals(constructor2) || equalityAxioms.equals(constructor1, constructor2); return constructor1.equals(constructor2) || equalityAxioms.equals(constructor1, constructor2);
@@ -21,7 +21,7 @@ import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.TypeConstructor; import org.jetbrains.jet.lang.types.TypeConstructor;
import org.jetbrains.jet.lang.types.TypeProjection; import org.jetbrains.jet.lang.types.TypeProjection;
class TypeCheckerTypingConstraints implements TypingConstraints { class TypeCheckerProcedureCallbacksImpl implements TypeCheckingProcedureCallbacks {
@Override @Override
public boolean assertEqualTypes(@NotNull JetType a, @NotNull JetType b, @NotNull TypeCheckingProcedure typeCheckingProcedure) { public boolean assertEqualTypes(@NotNull JetType a, @NotNull JetType b, @NotNull TypeCheckingProcedure typeCheckingProcedure) {
return typeCheckingProcedure.equalTypes(a, b); return typeCheckingProcedure.equalTypes(a, b);
@@ -32,19 +32,19 @@ public class TypeCheckingProcedure {
// as the second parameter, applying the substitution of type arguments to it // as the second parameter, applying the substitution of type arguments to it
@Nullable @Nullable
public static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) { public static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype) {
return findCorrespondingSupertype(subtype, supertype, new TypeCheckerTypingConstraints()); return findCorrespondingSupertype(subtype, supertype, new TypeCheckerProcedureCallbacksImpl());
} }
// This method returns the supertype of the first parameter that has the same constructor // This method returns the supertype of the first parameter that has the same constructor
// as the second parameter, applying the substitution of type arguments to it // as the second parameter, applying the substitution of type arguments to it
@Nullable @Nullable
public static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype, @NotNull TypingConstraints typingConstraints) { public static JetType findCorrespondingSupertype(@NotNull JetType subtype, @NotNull JetType supertype, @NotNull TypeCheckingProcedureCallbacks typeCheckingProcedureCallbacks) {
TypeConstructor constructor = subtype.getConstructor(); TypeConstructor constructor = subtype.getConstructor();
if (typingConstraints.assertEqualTypeConstructors(constructor, supertype.getConstructor())) { if (typeCheckingProcedureCallbacks.assertEqualTypeConstructors(constructor, supertype.getConstructor())) {
return subtype; return subtype;
} }
for (JetType immediateSupertype : constructor.getSupertypes()) { for (JetType immediateSupertype : constructor.getSupertypes()) {
JetType correspondingSupertype = findCorrespondingSupertype(immediateSupertype, supertype, typingConstraints); JetType correspondingSupertype = findCorrespondingSupertype(immediateSupertype, supertype, typeCheckingProcedureCallbacks);
if (correspondingSupertype != null) { if (correspondingSupertype != null) {
return TypeSubstitutor.create(subtype).safeSubstitute(correspondingSupertype, Variance.INVARIANT); return TypeSubstitutor.create(subtype).safeSubstitute(correspondingSupertype, Variance.INVARIANT);
} }
@@ -62,9 +62,9 @@ public class TypeCheckingProcedure {
return isOutProjected ? KotlinBuiltIns.getInstance().getNothingType() : argument.getType(); return isOutProjected ? KotlinBuiltIns.getInstance().getNothingType() : argument.getType();
} }
private final TypingConstraints constraints; private final TypeCheckingProcedureCallbacks constraints;
public TypeCheckingProcedure(TypingConstraints constraints) { public TypeCheckingProcedure(TypeCheckingProcedureCallbacks constraints) {
this.constraints = constraints; this.constraints = constraints;
} }
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.types.TypeProjection;
/** /**
* Methods of this class return true to continue type checking and false to fail * Methods of this class return true to continue type checking and false to fail
*/ */
public interface TypingConstraints { public interface TypeCheckingProcedureCallbacks {
boolean assertEqualTypes(@NotNull JetType a, @NotNull JetType b, @NotNull TypeCheckingProcedure typeCheckingProcedure); boolean assertEqualTypes(@NotNull JetType a, @NotNull JetType b, @NotNull TypeCheckingProcedure typeCheckingProcedure);
boolean assertEqualTypeConstructors(@NotNull TypeConstructor a, @NotNull TypeConstructor b); boolean assertEqualTypeConstructors(@NotNull TypeConstructor a, @NotNull TypeConstructor b);