diff --git a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt index 7a3e7e6ecde..6a96e9c2435 100644 --- a/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt +++ b/compiler/fir/providers/src/org/jetbrains/kotlin/fir/types/TypeUtils.kt @@ -259,7 +259,8 @@ fun T.withNullability( preserveEnhancedNullability: Boolean = false, ): T { val theAttributes = attributes.butIf(!preserveEnhancedNullability) { - it.remove(CompilerConeAttributes.EnhancedNullability) + val withoutEnhanced = it.remove(CompilerConeAttributes.EnhancedNullability) + withoutEnhanced.transformTypesWith { t -> t.withNullability(nullability, typeContext) } ?: withoutEnhanced } if (this.nullability == nullability && this.attributes == theAttributes) {