From a0d8e5bde7a6616732a85ddda5ccef504f6d918a Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Wed, 4 Dec 2019 18:23:58 +0300 Subject: [PATCH] [FIR] Don't create delegating constructor call to `kotlin.Annotation` --- .../fir/lightTree/converter/DeclarationsConverter.kt | 5 ++++- .../org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt | 5 ++++- .../testData/rawBuilder/expressions/annotated.txt | 2 +- .../rawBuilder/expressions/collectionLiterals.txt | 6 +++--- .../testData/resolve/expresssions/annotations.txt | 2 +- .../resolve/testData/resolve/multifile/Annotations.txt | 10 +++++----- 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt index b458141cb75..6cfda8837ec 100644 --- a/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt +++ b/compiler/fir/lightTree/src/org/jetbrains/kotlin/fir/lightTree/converter/DeclarationsConverter.kt @@ -397,7 +397,10 @@ class DeclarationsConverter( isNullable = false ) ) - modifiers.isAnnotation() && (classKind == ClassKind.ANNOTATION_CLASS) -> implicitAnnotationType + modifiers.isAnnotation() && (classKind == ClassKind.ANNOTATION_CLASS) -> { + superTypeRefs += implicitAnnotationType + implicitAnyType + } else -> implicitAnyType } diff --git a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt index 87c84026c1f..4f41704f848 100644 --- a/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt +++ b/compiler/fir/psi2fir/src/org/jetbrains/kotlin/fir/builder/RawFirBuilder.kt @@ -352,7 +352,10 @@ class RawFirBuilder(session: FirSession, val stubMode: Boolean) : BaseFirBuilder isNullable = false ) ) - this is KtClass && classKind == ClassKind.ANNOTATION_CLASS -> implicitAnnotationType + this is KtClass && classKind == ClassKind.ANNOTATION_CLASS -> { + container.superTypeRefs += implicitAnnotationType + implicitAnyType + } else -> implicitAnyType } // TODO: for enum / annotations, it *should* be empty diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.txt index 0478f1951a7..780b7b3eeab 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/annotated.txt @@ -1,7 +1,7 @@ FILE: annotated.kt @Target(AnnotationTarget#.EXPRESSION#) @Retention(AnnotationRetention#.SOURCE#) public? final? annotation class Ann : R|kotlin/Annotation| { public? constructor(): R|Ann| { - super() + super() } } diff --git a/compiler/fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.txt b/compiler/fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.txt index 5233e7a9732..753381c75cb 100644 --- a/compiler/fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.txt +++ b/compiler/fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.txt @@ -1,7 +1,7 @@ FILE: collectionLiterals.kt public? final? annotation class Ann1 : R|kotlin/Annotation| { public? constructor(arr: IntArray): R|Ann1| { - super() + super() } public? final? val arr: IntArray = R|/arr| @@ -10,7 +10,7 @@ FILE: collectionLiterals.kt } public? final? annotation class Ann2 : R|kotlin/Annotation| { public? constructor(arr: DoubleArray): R|Ann2| { - super() + super() } public? final? val arr: DoubleArray = R|/arr| @@ -19,7 +19,7 @@ FILE: collectionLiterals.kt } public? final? annotation class Ann3 : R|kotlin/Annotation| { public? constructor(arr: Array): R|Ann3| { - super() + super() } public? final? val arr: Array = R|/arr| diff --git a/compiler/fir/resolve/testData/resolve/expresssions/annotations.txt b/compiler/fir/resolve/testData/resolve/expresssions/annotations.txt index 52430d18eb2..e476ef9184f 100644 --- a/compiler/fir/resolve/testData/resolve/expresssions/annotations.txt +++ b/compiler/fir/resolve/testData/resolve/expresssions/annotations.txt @@ -1,7 +1,7 @@ FILE: annotations.kt public final annotation class MyAnn : R|kotlin/Annotation| { public constructor(): R|MyAnn| { - super() + super() } } diff --git a/compiler/fir/resolve/testData/resolve/multifile/Annotations.txt b/compiler/fir/resolve/testData/resolve/multifile/Annotations.txt index 8edd63b6d2c..a9c5e19f823 100644 --- a/compiler/fir/resolve/testData/resolve/multifile/Annotations.txt +++ b/compiler/fir/resolve/testData/resolve/multifile/Annotations.txt @@ -1,13 +1,13 @@ FILE: annotations.kt @R|kotlin/annotation/Target|(Q|kotlin/annotation/AnnotationTarget.FILE|, Q|kotlin/annotation/AnnotationTarget.FUNCTION|, Q|kotlin/annotation/AnnotationTarget.TYPE|, Q|kotlin/annotation/AnnotationTarget.PROPERTY_GETTER|) public final annotation class Simple : R|kotlin/Annotation| { public constructor(): R|annotations/Simple| { - super() + super() } } public final annotation class WithInt : R|kotlin/Annotation| { public constructor(value: R|kotlin/Int|): R|annotations/WithInt| { - super() + super() } public final val value: R|kotlin/Int| = R|/value| @@ -16,7 +16,7 @@ FILE: annotations.kt } public final annotation class WithString : R|kotlin/Annotation| { public constructor(s: R|kotlin/String|): R|annotations/WithString| { - super() + super() } public final val s: R|kotlin/String| = R|/s| @@ -25,7 +25,7 @@ FILE: annotations.kt } public final annotation class Complex : R|kotlin/Annotation| { public constructor(wi: R|annotations/WithInt|, ws: R|annotations/WithString|): R|annotations/Complex| { - super() + super() } public final val wi: R|annotations/WithInt| = R|/wi| @@ -37,7 +37,7 @@ FILE: annotations.kt } public final annotation class VeryComplex : R|kotlin/Annotation| { public constructor(f: R|kotlin/Float|, d: R|kotlin/Double|, b: R|kotlin/Boolean|, l: R|kotlin/Long|, n: R|kotlin/Int?|): R|annotations/VeryComplex| { - super() + super() } public final val f: R|kotlin/Float| = R|/f|