added renderers for constraint system and type bounds

moved classes
This commit is contained in:
Svetlana Isakova
2013-12-27 14:58:09 +04:00
parent 45abab2a2c
commit c5d9757b94
4 changed files with 77 additions and 20 deletions
@@ -40,8 +40,8 @@ import java.util.Set;
import static org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.EQUAL;
import static org.jetbrains.jet.lang.resolve.calls.inference.ConstraintSystemImpl.ConstraintKind.SUB_TYPE;
import static org.jetbrains.jet.lang.resolve.calls.inference.TypeBoundsImpl.BoundKind.*;
import static org.jetbrains.jet.lang.resolve.calls.inference.TypeBoundsImpl.Bound;
import static org.jetbrains.jet.lang.resolve.calls.inference.TypeBounds.BoundKind.*;
import static org.jetbrains.jet.lang.resolve.calls.inference.TypeBounds.Bound;
import static org.jetbrains.jet.lang.types.TypeUtils.CANT_INFER_TYPE_PARAMETER;
import static org.jetbrains.jet.lang.types.TypeUtils.DONT_CARE;
@@ -18,16 +18,22 @@ package org.jetbrains.jet.lang.resolve.calls.inference;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lang.types.Variance;
import java.util.Collection;
import java.util.Set;
public interface TypeBounds {
@NotNull
Variance getVarianceOfPosition();
@NotNull
TypeParameterDescriptor getTypeVariable();
@NotNull
Collection<Bound> getBounds();
boolean isEmpty();
@Nullable
@@ -35,4 +41,20 @@ public interface TypeBounds {
@NotNull
Collection<JetType> getValues();
enum BoundKind {
LOWER_BOUND, UPPER_BOUND, EXACT_BOUND
}
class Bound {
public final JetType type;
public final BoundKind kind;
public final ConstraintPosition position;
public Bound(@NotNull JetType type, @NotNull BoundKind kind, @NotNull ConstraintPosition position) {
this.type = type;
this.kind = kind;
this.position = position;
}
}
}
@@ -31,23 +31,9 @@ import java.util.Collection;
import java.util.Collections;
import java.util.Set;
import static org.jetbrains.jet.lang.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND;
public class TypeBoundsImpl implements TypeBounds {
public static enum BoundKind {
LOWER_BOUND, UPPER_BOUND, EXACT_BOUND
}
public static class Bound {
public final JetType type;
public final BoundKind kind;
public final ConstraintPosition position;
public Bound(@NotNull JetType type, @NotNull BoundKind kind, @NotNull ConstraintPosition position) {
this.type = type;
this.kind = kind;
this.position = position;
}
}
private final TypeParameterDescriptor typeVariable;
private final Variance varianceOfPosition;
private final Set<Bound> bounds = Sets.newLinkedHashSet();
@@ -78,6 +64,13 @@ public class TypeBoundsImpl implements TypeBounds {
return getValues().isEmpty();
}
@NotNull
@Override
public TypeParameterDescriptor getTypeVariable() {
return typeVariable;
}
@Override
@NotNull
public Collection<Bound> getBounds() {
return bounds;
@@ -175,7 +168,7 @@ public class TypeBoundsImpl implements TypeBounds {
values.addAll(exactBounds);
Pair<Collection<JetType>, Collection<JetType>> pair =
TypeUtils.filterNumberTypes(filterBounds(bounds, BoundKind.LOWER_BOUND, values));
TypeUtils.filterNumberTypes(filterBounds(bounds, LOWER_BOUND, values));
Collection<JetType> generalLowerBounds = pair.getFirst();
Collection<JetType> numberLowerBounds = pair.getSecond();