Do not use parameter descriptors in most annotation implementations

Except AnnotationDescriptorImpl, which is refactored in the subsequent
commit.

Note that we no longer check the presence of parameters with the
corresponding names in the annotation class in
LazyJavaAnnotationDescriptor, this is why test data changed
This commit is contained in:
Alexander Udalov
2017-07-04 16:27:06 +03:00
parent cc7ed2ba54
commit eb205f620c
9 changed files with 53 additions and 91 deletions
@@ -126,19 +126,18 @@ class LazyAnnotationDescriptor(
c.scope
}
override val valueArgumentsByParameterDescriptor by c.storageManager.createLazyValue {
override val allValueArguments by c.storageManager.createLazyValue {
val resolutionResults = c.annotationResolver.resolveAnnotationCall(annotationEntry, scope, c.trace)
AnnotationResolverImpl.checkAnnotationType(annotationEntry, c.trace, resolutionResults)
if (!resolutionResults.isSingleResult) return@createLazyValue emptyMap<ValueParameterDescriptor, ConstantValue<*>>()
if (!resolutionResults.isSingleResult) return@createLazyValue emptyMap<Name, ConstantValue<*>>()
@Suppress("UNCHECKED_CAST")
resolutionResults.resultingCall.valueArguments
.mapValues { val (valueParameter, resolvedArgument) = it
if (resolvedArgument == null) null
else c.annotationResolver.getAnnotationArgumentValue(c.trace, valueParameter, resolvedArgument)
}
.filterValues { it != null } as Map<ValueParameterDescriptor, ConstantValue<*>>
resolutionResults.resultingCall.valueArguments.mapNotNull { (valueParameter, resolvedArgument) ->
if (resolvedArgument == null) null
else c.annotationResolver.getAnnotationArgumentValue(c.trace, valueParameter, resolvedArgument)?.let { value ->
valueParameter.name to value
}
}.toMap()
}
override fun forceResolveAllContents() {