Annotated the return type of 'elvis' function with @Exact
fun <T> ELVIS(T?, T): @Exact T
This commit is contained in:
@@ -80,6 +80,11 @@ class FilteredAnnotations(
|
||||
private val delegate: Annotations,
|
||||
private val fqNameFilter: (FqName) -> Boolean
|
||||
) : Annotations {
|
||||
|
||||
override fun hasAnnotation(fqName: FqName) =
|
||||
if (fqNameFilter(fqName)) delegate.hasAnnotation(fqName)
|
||||
else false
|
||||
|
||||
override fun findAnnotation(fqName: FqName) =
|
||||
if (fqNameFilter(fqName)) delegate.findAnnotation(fqName)
|
||||
else null
|
||||
@@ -115,6 +120,8 @@ class CompositeAnnotations(
|
||||
|
||||
override fun isEmpty() = delegates.all { it.isEmpty() }
|
||||
|
||||
override fun hasAnnotation(fqName: FqName) = delegates.asSequence().any { it.hasAnnotation(fqName) }
|
||||
|
||||
override fun findAnnotation(fqName: FqName) = delegates.asSequence().map { it.findAnnotation(fqName) }.filterNotNull().firstOrNull()
|
||||
|
||||
override fun findExternalAnnotation(fqName: FqName) = delegates.asSequence().map { it.findExternalAnnotation(fqName) }.filterNotNull().firstOrNull()
|
||||
|
||||
@@ -18,6 +18,8 @@ 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.types.KotlinType
|
||||
@@ -40,4 +42,22 @@ public fun CallableDescriptor.hasLowPriorityInOverloadResolution(): Boolean = an
|
||||
|
||||
private val ONLY_INPUT_TYPES_FQ_NAME = FqName("kotlin.internal.OnlyInputTypes")
|
||||
|
||||
public fun TypeParameterDescriptor.hasOnlyInputTypesAnnotation(): Boolean = annotations.hasAnnotation(ONLY_INPUT_TYPES_FQ_NAME)
|
||||
public fun TypeParameterDescriptor.hasOnlyInputTypesAnnotation(): Boolean = annotations.hasAnnotation(ONLY_INPUT_TYPES_FQ_NAME)
|
||||
|
||||
public fun getExactInAnnotations(): Annotations = AnnotationsWithOnly(EXACT_ANNOTATION_FQ_NAME)
|
||||
|
||||
private class AnnotationsWithOnly(val presentAnnotation: FqName): Annotations {
|
||||
override fun iterator(): Iterator<AnnotationDescriptor> = listOf<AnnotationDescriptor>().iterator()
|
||||
|
||||
override fun isEmpty(): Boolean = false
|
||||
|
||||
override fun hasAnnotation(fqName: FqName): Boolean = fqName == this.presentAnnotation
|
||||
|
||||
override fun findAnnotation(fqName: FqName): AnnotationDescriptor? = null
|
||||
|
||||
override fun findExternalAnnotation(fqName: FqName): AnnotationDescriptor? = null
|
||||
|
||||
override fun getUseSiteTargetedAnnotations(): List<AnnotationWithTarget> = emptyList()
|
||||
|
||||
override fun getAllAnnotations(): List<AnnotationWithTarget> = emptyList()
|
||||
}
|
||||
Reference in New Issue
Block a user