[FIR] Fix infinite loop in attribute substitution
#KT-65318 Fixed
This commit is contained in:
committed by
Space Team
parent
d047db850f
commit
9e72482f09
+11
-1
@@ -89,7 +89,17 @@ abstract class AbstractConeSubstitutor(protected val typeContext: ConeTypeContex
|
||||
}
|
||||
|
||||
val substitutedType = newType ?: type.substituteRecursive()
|
||||
val substitutedAttributes = (substitutedType ?: type).attributes.transformTypesWith(this::substituteOrNull)
|
||||
|
||||
// Don't substitute attributes of flexible types because their bounds will be processed individually.
|
||||
val substitutedAttributesOfUnsubstitutedType = runIf(type !is ConeFlexibleType) {
|
||||
type.attributes.transformTypesWith(this::substituteOrNull)
|
||||
}
|
||||
val substitutedAttributes = substitutedAttributesOfUnsubstitutedType?.let {
|
||||
// ConeAttribute.add is typically implemented to favor the RHS if both are not-null, so we use the substituted attributes as RHS.
|
||||
// We can't do `(substitutedType ?: type).attributes.transformTypesWith(this::substituteOrNull)` because it could lead to an
|
||||
// infinite loop in a situation like `{E -> Attr(E) Foo}` applied to `E`.
|
||||
substitutedType?.attributes?.add(it) ?: it
|
||||
}
|
||||
|
||||
return if (substitutedType != null || substitutedAttributes != null) {
|
||||
var result = substitutedType ?: type
|
||||
|
||||
Reference in New Issue
Block a user