From f9b9b6908a39c3f280e0796a5d63ff6aa46ed89f Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Wed, 22 Aug 2018 19:54:23 +0200 Subject: [PATCH] Remove use-site targeted annotations from LazyAnnotations LazyAnnotations are only used for classes and files, and in the latter case it will now contain file annotations as normal annotations, without the target "file:" --- .../lazy/descriptors/LazyAnnotations.kt | 21 +++---------------- .../withUseSiteTarget/DelegateAnnotations.txt | 2 +- .../withUseSiteTarget/FieldAnnotations.txt | 2 +- .../withUseSiteTarget/GetterAnnotations.txt | 2 +- .../withUseSiteTarget/ParamAnnotations.txt | 2 +- .../withUseSiteTarget/PropertyAnnotations.txt | 2 +- .../withUseSiteTarget/ReceiverAnnotations.txt | 2 +- .../withUseSiteTarget/SetterAnnotations.txt | 2 +- .../withUseSiteTarget/SparamAnnotations.txt | 2 +- .../diagnosticFileAnnotationInWrongPlace.txt | 2 +- 10 files changed, 12 insertions(+), 27 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt index 8832dd08135..d4a593de254 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt @@ -56,27 +56,12 @@ class LazyAnnotations( override fun isEmpty() = annotationEntries.isEmpty() private val annotation = c.storageManager.createMemoizedFunction { entry: KtAnnotationEntry -> - val descriptor = LazyAnnotationDescriptor(c, entry) - val target = entry.useSiteTarget?.getAnnotationUseSiteTarget() - AnnotationWithTarget(descriptor, target) + LazyAnnotationDescriptor(c, entry) } - override fun getUseSiteTargetedAnnotations(): List { - return annotationEntries - .mapNotNull { - val (descriptor, target) = annotation(it) - if (target == null) null else AnnotationWithTarget(descriptor, target) - } - } + override fun getUseSiteTargetedAnnotations(): List = emptyList() - override fun iterator(): Iterator { - return annotationEntries - .asSequence() - .mapNotNull { - val (descriptor, target) = annotation(it) - if (target == null) descriptor else null // Filter out annotations with target - }.iterator() - } + override fun iterator(): Iterator = annotationEntries.asSequence().map(annotation).iterator() override fun forceResolveAllContents() { // To resolve all entries diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/DelegateAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/DelegateAnnotations.txt index 564640865b2..ded73b7856a 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/DelegateAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/DelegateAnnotations.txt @@ -24,7 +24,7 @@ public final class CustomDelegate { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class SomeClass { +@Field public final class SomeClass { public constructor SomeClass() @delegate:Field @delegate:Prop protected final val delegatedProperty: kotlin.String public final val propertyWithCustomGetter: kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FieldAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FieldAnnotations.txt index 88953b83e49..f9ccb8f496a 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FieldAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/FieldAnnotations.txt @@ -15,7 +15,7 @@ public final class CustomDelegate { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class SomeClass { +@Ann public final class SomeClass { public constructor SomeClass() protected final val delegatedProperty: kotlin.String public final val propertyWithCustomGetter: kotlin.Int diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.txt index 68b3511ffa4..8280f1b00e2 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/GetterAnnotations.txt @@ -15,7 +15,7 @@ public final class CustomDelegate { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class SomeClass { +@Ann public final class SomeClass { public constructor SomeClass() protected final val delegatedProperty: kotlin.String protected final var mutableProperty: kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ParamAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ParamAnnotations.txt index 2596a2bca2e..66f7428e082 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ParamAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ParamAnnotations.txt @@ -22,7 +22,7 @@ public final annotation class Second : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class SomeClass { +@Ann public final class SomeClass { public constructor SomeClass(/*0*/ a: kotlin.String) protected final val simpleProperty: kotlin.String = "text" public final fun anotherFun(): kotlin.Unit diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.txt index 79e2dd175fe..95479ffd5ec 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/PropertyAnnotations.txt @@ -22,7 +22,7 @@ public final annotation class Second : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class SomeClass { +@Ann public final class SomeClass { public constructor SomeClass(/*0*/ s: kotlin.String) @Ann protected final val p1: kotlin.String = "" @Ann @Second protected final val p2: kotlin.String = "" diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.txt index 62db3c82aff..3e8ee9a87c9 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/ReceiverAnnotations.txt @@ -10,7 +10,7 @@ public final annotation class Ann : kotlin.Annotation { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class SomeClass { +@Ann public final class SomeClass { public constructor SomeClass(/*0*/ a: kotlin.String) protected final val simpleProperty: kotlin.String = "text" public final val @receiver:Ann kotlin.String.extensionProperty2: kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SetterAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SetterAnnotations.txt index 9f06d405834..fa1844352b4 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SetterAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SetterAnnotations.txt @@ -16,7 +16,7 @@ public final class CustomDelegate { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class SomeClass { +@Ann public final class SomeClass { public constructor SomeClass() protected final var delegatedProperty: kotlin.String protected final var mutableProperty: kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.txt index 76279334f47..45d91ab5ee9 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/SparamAnnotations.txt @@ -16,7 +16,7 @@ public final class CustomDelegate { public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String } -public final class SomeClass { +@Ann public final class SomeClass { public constructor SomeClass() @setparam:Ann protected final var delegatedProperty: kotlin.String @setparam:Ann protected final var mutableProperty: kotlin.String diff --git a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticFileAnnotationInWrongPlace.txt b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticFileAnnotationInWrongPlace.txt index c67269852c3..eb001fff7d3 100644 --- a/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticFileAnnotationInWrongPlace.txt +++ b/compiler/testData/diagnostics/tests/annotations/withUseSiteTarget/diagnosticFileAnnotationInWrongPlace.txt @@ -4,7 +4,7 @@ package bar { public val prop: [ERROR : No type, no body] public fun func(): kotlin.Unit - public final class C { + @bar.baz public final class C { public constructor C() public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int