added assert that constraining type doesn't contain type variables
This commit is contained in:
+26
-13
@@ -136,21 +136,16 @@ public class ConstraintsSystemImpl implements ConstraintsSystem {
|
|||||||
DeclarationDescriptor subjectTypeDescriptor = subjectType.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor subjectTypeDescriptor = subjectType.getConstructor().getDeclarationDescriptor();
|
||||||
|
|
||||||
if (subjectTypeDescriptor instanceof TypeParameterDescriptor) {
|
if (subjectTypeDescriptor instanceof TypeParameterDescriptor) {
|
||||||
if (TypeUtils.dependsOnTypeParameterConstructors(constrainingType, Collections.singleton(DONT_CARE.getConstructor()))) return;
|
|
||||||
if (subjectType.isNullable()) {
|
|
||||||
constrainingType = TypeUtils.makeNotNullable(constrainingType);
|
|
||||||
}
|
|
||||||
TypeParameterDescriptor typeParameter = (TypeParameterDescriptor) subjectTypeDescriptor;
|
TypeParameterDescriptor typeParameter = (TypeParameterDescriptor) subjectTypeDescriptor;
|
||||||
if (constraintKind == ConstraintKind.SUPER_TYPE) {
|
TypeConstraintsImpl typeConstraints = typeParameterConstraints.get(typeParameter);
|
||||||
typeParameterConstraints.get(typeParameter).addLowerBound(constrainingType);
|
if (typeConstraints != null) {
|
||||||
|
addBoundToTypeConstraints(constraintKind, subjectType, constrainingType, typeConstraints);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
else if (constraintKind == ConstraintKind.SUB_TYPE) {
|
}
|
||||||
typeParameterConstraints.get(typeParameter).addUpperBound(constrainingType);
|
if (constrainingTypeDescriptor instanceof TypeParameterDescriptor) {
|
||||||
}
|
// assert that constraining type doesn't contain type variables
|
||||||
else {
|
assert typeParameterConstraints.get(constrainingTypeDescriptor) == null;
|
||||||
typeParameterConstraints.get(typeParameter).addExactBound(constrainingType);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (constrainingTypeDescriptor instanceof ClassDescriptor && subjectTypeDescriptor instanceof ClassDescriptor) {
|
if (constrainingTypeDescriptor instanceof ClassDescriptor && subjectTypeDescriptor instanceof ClassDescriptor) {
|
||||||
@@ -190,6 +185,24 @@ public class ConstraintsSystemImpl implements ConstraintsSystem {
|
|||||||
errorConstraintPositions.add(constraintPosition);
|
errorConstraintPositions.add(constraintPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void addBoundToTypeConstraints(@NotNull ConstraintKind constraintKind, @NotNull JetType subjectType,
|
||||||
|
@NotNull JetType constrainingType, @NotNull TypeConstraintsImpl typeConstraints) {
|
||||||
|
|
||||||
|
if (TypeUtils.dependsOnTypeParameterConstructors(constrainingType, Collections.singleton(DONT_CARE.getConstructor()))) return;
|
||||||
|
if (subjectType.isNullable()) {
|
||||||
|
constrainingType = TypeUtils.makeNotNullable(constrainingType);
|
||||||
|
}
|
||||||
|
if (constraintKind == ConstraintKind.SUPER_TYPE) {
|
||||||
|
typeConstraints.addLowerBound(constrainingType);
|
||||||
|
}
|
||||||
|
else if (constraintKind == ConstraintKind.SUB_TYPE) {
|
||||||
|
typeConstraints.addUpperBound(constrainingType);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
typeConstraints.addExactBound(constrainingType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Set<TypeParameterDescriptor> getTypeVariables() {
|
public Set<TypeParameterDescriptor> getTypeVariables() {
|
||||||
|
|||||||
Reference in New Issue
Block a user