[FE 1.0] Keep the same type attributes during union or intersection type attributes

^KT-51317 Fixed
This commit is contained in:
Victor Petukhov
2022-05-16 17:17:45 +02:00
parent e009d6a074
commit 88d35067e3
8 changed files with 61 additions and 2 deletions
@@ -10,9 +10,11 @@ import org.jetbrains.kotlin.descriptors.annotations.composeAnnotations
import kotlin.reflect.KClass
class AnnotationsTypeAttribute(val annotations: Annotations) : TypeAttribute<AnnotationsTypeAttribute>() {
override fun union(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = null
override fun union(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? =
if (other == this) this else null
override fun intersect(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? = null
override fun intersect(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute? =
if (other == this) this else null
override fun add(other: AnnotationsTypeAttribute?): AnnotationsTypeAttribute {
if (other == null) return this
@@ -23,6 +25,13 @@ class AnnotationsTypeAttribute(val annotations: Annotations) : TypeAttribute<Ann
override val key: KClass<out AnnotationsTypeAttribute>
get() = AnnotationsTypeAttribute::class
override fun equals(other: Any?): Boolean {
if (other !is AnnotationsTypeAttribute) return false
return other.annotations == this.annotations
}
override fun hashCode(): Int = annotations.hashCode()
}
val TypeAttributes.annotationsAttribute: AnnotationsTypeAttribute? by TypeAttributes.attributeAccessor<AnnotationsTypeAttribute>()