From 62ba1277bb034f58529b791e9684e9abcb3b44ff Mon Sep 17 00:00:00 2001 From: Mikhail Glukhikh Date: Fri, 7 Oct 2022 11:19:43 +0200 Subject: [PATCH] K2: don't duplicate custom annotations in types #KT-54275 Fixed --- .../problems/exceptionInRepeatedAnnotation.fir.txt | 2 +- .../jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/exceptionInRepeatedAnnotation.fir.txt b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/exceptionInRepeatedAnnotation.fir.txt index 3f32c97a821..3683345fd9e 100644 --- a/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/exceptionInRepeatedAnnotation.fir.txt +++ b/compiler/fir/analysis-tests/testData/resolveWithStdlib/problems/exceptionInRepeatedAnnotation.fir.txt @@ -20,7 +20,7 @@ FILE: exceptionInRepeatedAnnotation.kt public final inline fun R|EventHandler|.withPriority(): R|EventListener<@R|kotlin/ParameterName|(name = String(e)) E>| { ^withPriority Q|EventListener|.R|/EventListener.Companion.invoke|(this@R|/withPriority|) } - public final inline fun R|EventHandler|.withDefaultPriority(): R|EventListener<@R|kotlin/ParameterName|(name = String(e)) @R|kotlin/ParameterName|(name = String(e)) E>| { + public final inline fun R|EventHandler|.withDefaultPriority(): R|EventListener<@R|kotlin/ParameterName|(name = String(e)) E>| { ^withDefaultPriority this@R|/withDefaultPriority|.R|/withPriority|() } public abstract class Event : R|kotlin/Any| { diff --git a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt index f02c2ef2226..36f79c85097 100644 --- a/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt +++ b/compiler/fir/tree/src/org/jetbrains/kotlin/fir/types/CustomAnnotationTypeAttribute.kt @@ -15,7 +15,7 @@ class CustomAnnotationTypeAttribute(val annotations: List) : Cone override fun intersect(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute? = null override fun add(other: CustomAnnotationTypeAttribute?): CustomAnnotationTypeAttribute { - if (other == null) return this + if (other == null || other === this) return this return CustomAnnotationTypeAttribute(annotations + other.annotations) }