fixed bug in constraint system
For parameter type T constraint T? <: Int? should NOT transform to T <: Int, it should be T <: Int? equality constraint T? = Int? should transform to T <: Int? && T >: Int
This commit is contained in:
+14
-4
@@ -336,11 +336,21 @@ public class ConstraintSystemImpl implements ConstraintSystem {
|
||||
TypeConstraintsImpl typeConstraints = getTypeConstraints(parameterType);
|
||||
assert typeConstraints != null : "constraint should be generated only for type variables";
|
||||
|
||||
if (parameterType.isNullable()) {
|
||||
// For parameter type T constraint T? <: Int? should transform to T <: Int
|
||||
constrainingType = TypeUtils.makeNotNullable(constrainingType);
|
||||
if (!parameterType.isNullable() || !constrainingType.isNullable()) {
|
||||
typeConstraints.addBound(boundKind, constrainingType);
|
||||
return;
|
||||
}
|
||||
// For parameter type T:
|
||||
// constraint T? = Int? should transform to T >: Int and T <: Int?
|
||||
// constraint T? >: Int? should transform to T >: Int
|
||||
JetType notNullConstrainingType = TypeUtils.makeNotNullable(constrainingType);
|
||||
if (boundKind == EXACT_BOUND || boundKind == LOWER_BOUND) {
|
||||
typeConstraints.addBound(LOWER_BOUND, notNullConstrainingType);
|
||||
}
|
||||
// constraint T? <: Int? should transform to T <: Int?
|
||||
if (boundKind == EXACT_BOUND || boundKind == UPPER_BOUND) {
|
||||
typeConstraints.addBound(UPPER_BOUND, constrainingType);
|
||||
}
|
||||
typeConstraints.addBound(boundKind, constrainingType);
|
||||
}
|
||||
|
||||
public void processDeclaredBoundConstraints() {
|
||||
|
||||
Reference in New Issue
Block a user