Fixes and refactors

This commit is contained in:
Irene Dea
2021-10-21 13:22:51 -07:00
committed by Dmitriy Novozhilov
parent 2e2e70fede
commit 19bfc43bee
70 changed files with 263 additions and 327 deletions
@@ -60,7 +60,14 @@ class MutableVariableWithConstraints private constructor(
&& previousConstraint.isNullabilityConstraint == constraint.isNullabilityConstraint
) {
if (newConstraintIsUseless(previousConstraint, constraint)) {
return previousConstraint to false
// Preserve constraints with different custom type attributes.
// This allows us to union type attributes in NewCommonSuperTypeCalculator.kt
with(context) {
val prevAttributes = previousConstraint.type.getCustomAttributes()
if (prevAttributes.isEmpty() || prevAttributes == constraint.type.getCustomAttributes()) {
return previousConstraint to false
}
}
}
val isMatchingForSimplification = when (previousConstraint.kind) {
@@ -139,11 +146,7 @@ class MutableVariableWithConstraints private constructor(
return false
return when (old.kind) {
ConstraintKind.EQUALITY -> {
with(context) {
old.type.getAttributes() == new.type.getAttributes()
}
}
ConstraintKind.EQUALITY -> true
ConstraintKind.LOWER -> new.kind.isLower()
ConstraintKind.UPPER -> new.kind.isUpper()
}