Provide default implementation for Annotations.getUseSiteTargetedAnnotations
After this commit, it's overridden only in AnnotationsImpl and CompositeAnnotations. Note that although FilteredAnnotations did have a non-trivial implementation, that class was only used in circumstances where annotations with use-site targets could not be of any use, so it's safe to return empty list there now. One could argue that the new semantics makes more sense: filter "standard" annotations, but don't touch those with use-site targets because they are not applied to this element directly, thus should likely not be affected by the filtering
This commit is contained in:
-1
@@ -146,7 +146,6 @@ class AnnotationSplitter(
|
||||
override fun isEmpty() = annotations.isEmpty()
|
||||
override fun hasAnnotation(fqName: FqName) = annotations.hasAnnotation(fqName)
|
||||
override fun findAnnotation(fqName: FqName) = annotations.findAnnotation(fqName)
|
||||
override fun getUseSiteTargetedAnnotations() = annotations.getUseSiteTargetedAnnotations()
|
||||
override fun iterator() = annotations.iterator()
|
||||
override fun toString() = annotations.toString()
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.resolve.lazy.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtAnnotationEntry
|
||||
@@ -59,8 +58,6 @@ class LazyAnnotations(
|
||||
LazyAnnotationDescriptor(c, entry)
|
||||
}
|
||||
|
||||
override fun getUseSiteTargetedAnnotations(): List<AnnotationWithTarget> = emptyList()
|
||||
|
||||
override fun iterator(): Iterator<AnnotationDescriptor> = annotationEntries.asSequence().map(annotation).iterator()
|
||||
|
||||
override fun forceResolveAllContents() {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.load.java.lazy
|
||||
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.load.java.components.JavaAnnotationMapper
|
||||
import org.jetbrains.kotlin.load.java.structure.JavaAnnotation
|
||||
@@ -36,8 +35,6 @@ class LazyJavaAnnotations(
|
||||
annotationOwner.findAnnotation(fqName)?.let(annotationDescriptors)
|
||||
?: JavaAnnotationMapper.findMappedJavaAnnotation(fqName, annotationOwner, c)
|
||||
|
||||
override fun getUseSiteTargetedAnnotations() = emptyList<AnnotationWithTarget>()
|
||||
|
||||
override fun iterator() =
|
||||
(annotationOwner.annotations.asSequence().map(annotationDescriptors)
|
||||
+ JavaAnnotationMapper.findMappedJavaAnnotation(KotlinBuiltIns.FQ_NAMES.deprecated, annotationOwner, c)).filterNotNull().iterator()
|
||||
|
||||
-3
@@ -21,7 +21,6 @@ import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.SourceElement
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
@@ -198,8 +197,6 @@ private class EnhancedTypeAnnotations(private val fqNameToMatch: FqName) : Annot
|
||||
else -> null
|
||||
}
|
||||
|
||||
override fun getUseSiteTargetedAnnotations() = emptyList<AnnotationWithTarget>()
|
||||
|
||||
// Note, that this class may break Annotations contract (!isEmpty && iterator.isEmpty())
|
||||
// It's a hack that we need unless we have stable "user data" in JetType
|
||||
override fun iterator(): Iterator<AnnotationDescriptor> = emptyList<AnnotationDescriptor>().iterator()
|
||||
|
||||
@@ -35,7 +35,7 @@ interface Annotations : Iterable<AnnotationDescriptor> {
|
||||
|
||||
fun hasAnnotation(fqName: FqName): Boolean = findAnnotation(fqName) != null
|
||||
|
||||
fun getUseSiteTargetedAnnotations(): List<AnnotationWithTarget>
|
||||
fun getUseSiteTargetedAnnotations(): List<AnnotationWithTarget> = emptyList()
|
||||
|
||||
companion object {
|
||||
val EMPTY: Annotations = object : Annotations {
|
||||
@@ -43,8 +43,6 @@ interface Annotations : Iterable<AnnotationDescriptor> {
|
||||
|
||||
override fun findAnnotation(fqName: FqName) = null
|
||||
|
||||
override fun getUseSiteTargetedAnnotations() = emptyList<AnnotationWithTarget>()
|
||||
|
||||
override fun iterator() = emptyList<AnnotationDescriptor>().iterator()
|
||||
|
||||
override fun toString() = "EMPTY"
|
||||
@@ -65,10 +63,6 @@ class FilteredAnnotations(
|
||||
if (fqNameFilter(fqName)) delegate.findAnnotation(fqName)
|
||||
else null
|
||||
|
||||
override fun getUseSiteTargetedAnnotations(): List<AnnotationWithTarget> {
|
||||
return delegate.getUseSiteTargetedAnnotations().filter { shouldBeReturned(it.annotation) }
|
||||
}
|
||||
|
||||
override fun iterator() = delegate.filter(this::shouldBeReturned).iterator()
|
||||
|
||||
override fun isEmpty() = delegate.any(this::shouldBeReturned)
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.jetbrains.kotlin.resolve.descriptorUtil
|
||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -48,6 +47,4 @@ private class AnnotationsWithOnly(val presentAnnotation: FqName): Annotations {
|
||||
override fun isEmpty(): Boolean = false
|
||||
|
||||
override fun hasAnnotation(fqName: FqName): Boolean = fqName == this.presentAnnotation
|
||||
|
||||
override fun getUseSiteTargetedAnnotations(): List<AnnotationWithTarget> = emptyList()
|
||||
}
|
||||
|
||||
-3
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.serialization.deserialization.descriptors
|
||||
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationWithTarget
|
||||
import org.jetbrains.kotlin.descriptors.annotations.Annotations
|
||||
import org.jetbrains.kotlin.storage.StorageManager
|
||||
import org.jetbrains.kotlin.storage.getValue
|
||||
@@ -30,8 +29,6 @@ open class DeserializedAnnotations(
|
||||
|
||||
override fun isEmpty(): Boolean = annotations.isEmpty()
|
||||
|
||||
override fun getUseSiteTargetedAnnotations(): List<AnnotationWithTarget> = emptyList()
|
||||
|
||||
override fun iterator(): Iterator<AnnotationDescriptor> = annotations.iterator()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user