[FIR] Preserve enhanced mutability when nullability was enhanced for warning

#KT-56989
This commit is contained in:
Kirill Rakhman
2023-10-23 11:57:32 +02:00
committed by Space Team
parent a63ec9efdc
commit 2005446296
10 changed files with 118 additions and 12 deletions
@@ -106,7 +106,14 @@ private fun ConeSimpleKotlinType.enhanceInflexibleType(
)
return if (effectiveQualifiers.isNullabilityQualifierForWarning && enhanced != null) {
this.withAttributes(attributes.plus(EnhancedTypeForWarningAttribute(enhanced)))
val newAttributes = attributes.plus(EnhancedTypeForWarningAttribute(enhanced))
if (enhancedTag != lookupTag) {
// Handle case when mutability was enhanced and nullability was enhanced for warning.
enhancedTag.constructType(typeArguments, isNullable, newAttributes)
} else {
this.withAttributes(newAttributes)
}
} else {
enhanced
}