K2: drop unnecessary attributes when inferring declaration types

Related to KT-62578
This commit is contained in:
Mikhail Glukhikh
2023-10-17 13:44:40 +02:00
committed by Space Team
parent 90eaf5f70f
commit cebb6747e3
5 changed files with 29 additions and 13 deletions
@@ -125,6 +125,11 @@ class ConeAttributes private constructor(attributes: List<ConeAttribute<*>>) : A
})
}
fun filterNecessaryToKeep(): ConeAttributes {
return if (all { it.keepInInferredDeclarationType }) this
else create(filter { it.keepInInferredDeclarationType })
}
private inline fun perform(other: ConeAttributes, op: ConeAttribute<*>.(ConeAttribute<*>?) -> ConeAttribute<*>?): ConeAttributes {
if (this.isEmpty() && other.isEmpty()) return this
val attributes = mutableListOf<ConeAttribute<*>>()