Change map key type in AnnotationDescriptor.getAllValueArguments
Turns out, only the parameter's name is needed at all usages of this method. Such a map is both easier to use (no need to call ValueParameterDescriptor.getName) and easier to construct (no need to resolve annotation class, its constructor, its parameters). In this commit, only usages have changed but the implementations are still using the old logic, this is going to be refactored in subsequent commits
This commit is contained in:
@@ -19,8 +19,8 @@ package org.jetbrains.kotlin.resolve.annotations
|
||||
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||
import org.jetbrains.kotlin.resolve.constants.ConstantValue
|
||||
import org.jetbrains.kotlin.resolve.constants.ErrorValue
|
||||
|
||||
private val JVM_STATIC_ANNOTATION_FQ_NAME = FqName("kotlin.jvm.JvmStatic")
|
||||
@@ -42,12 +42,5 @@ fun DeclarationDescriptor.findStrictfpAnnotation() =
|
||||
DescriptorUtils.getAnnotationByFqName(annotations, STRICTFP_ANNOTATION_FQ_NAME)
|
||||
|
||||
fun AnnotationDescriptor.argumentValue(parameterName: String): Any? {
|
||||
val constant: ConstantValue<*>? = allValueArguments.entries
|
||||
.singleOrNull { it.key.name.asString() == parameterName }
|
||||
?.value
|
||||
|
||||
if (constant == null || constant is ErrorValue)
|
||||
return null
|
||||
|
||||
return constant.value
|
||||
return allValueArguments[Name.identifier(parameterName)].takeUnless { it is ErrorValue }?.value
|
||||
}
|
||||
|
||||
+1
-1
@@ -126,7 +126,7 @@ class LazyAnnotationDescriptor(
|
||||
c.scope
|
||||
}
|
||||
|
||||
override val allValueArguments by c.storageManager.createLazyValue {
|
||||
override val valueArgumentsByParameterDescriptor by c.storageManager.createLazyValue {
|
||||
val resolutionResults = c.annotationResolver.resolveAnnotationCall(annotationEntry, scope, c.trace)
|
||||
AnnotationResolverImpl.checkAnnotationType(annotationEntry, c.trace, resolutionResults)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user