ConstraintKind moved to TypeConstraintsImpl
This commit is contained in:
+31
-11
@@ -18,7 +18,6 @@ package org.jetbrains.jet.lang.resolve.calls.inference;
|
|||||||
|
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.Variance;
|
import org.jetbrains.jet.lang.types.Variance;
|
||||||
|
|
||||||
@@ -43,16 +42,17 @@ public class TypeConstraintsImpl implements TypeConstraints {
|
|||||||
return varianceOfPosition;
|
return varianceOfPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addUpperBound(@NotNull JetType type) {
|
public void addBound(@NotNull ConstraintKind constraintKind, @NotNull JetType type) {
|
||||||
upperBounds.add(type);
|
switch (constraintKind) {
|
||||||
}
|
case SUPER_TYPE:
|
||||||
|
lowerBounds.add(type);
|
||||||
public void addLowerBound(@NotNull JetType type) {
|
break;
|
||||||
lowerBounds.add(type);
|
case SUB_TYPE:
|
||||||
}
|
upperBounds.add(type);
|
||||||
|
break;
|
||||||
public void addExactBound(@NotNull JetType type) {
|
case EQUAL:
|
||||||
exactBounds.add(type);
|
exactBounds.add(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,4 +77,24 @@ public class TypeConstraintsImpl implements TypeConstraints {
|
|||||||
public Set<JetType> getExactBounds() {
|
public Set<JetType> getExactBounds() {
|
||||||
return exactBounds;
|
return exactBounds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static enum ConstraintKind {
|
||||||
|
SUB_TYPE, SUPER_TYPE, EQUAL;
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
static ConstraintKind fromVariance(@NotNull Variance variance) {
|
||||||
|
ConstraintKind constraintKind = null;
|
||||||
|
switch (variance) {
|
||||||
|
case INVARIANT:
|
||||||
|
constraintKind = EQUAL;
|
||||||
|
break;
|
||||||
|
case OUT_VARIANCE:
|
||||||
|
constraintKind = SUPER_TYPE;
|
||||||
|
break;
|
||||||
|
case IN_VARIANCE:
|
||||||
|
constraintKind = SUB_TYPE;
|
||||||
|
}
|
||||||
|
return constraintKind;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user