From 802528299b1282e69759241834ec5b9279e079d0 Mon Sep 17 00:00:00 2001 From: Jiaxiang Chen Date: Wed, 15 Nov 2023 13:22:52 -0800 Subject: [PATCH] annotation call resolver: lookup scope before creating one --- .../ksp/symbol/impl/binary/KSAnnotationDescriptorImpl.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/binary/KSAnnotationDescriptorImpl.kt b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/binary/KSAnnotationDescriptorImpl.kt index e4dfeca2e1..dc682c2557 100644 --- a/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/binary/KSAnnotationDescriptorImpl.kt +++ b/compiler-plugin/src/main/kotlin/com/google/devtools/ksp/symbol/impl/binary/KSAnnotationDescriptorImpl.kt @@ -193,9 +193,10 @@ fun LazyAnnotationDescriptor.getValueArguments(): Map> { override fun toString(): String = "${name.asString()} declared in LazyAnnotations.kt" } - val scope = (c.scope.ownerDescriptor as? PackageFragmentDescriptor)?.let { - LexicalScope.Base(c.scope, FileDescriptorForVisibilityChecks(source, it)) - } ?: c.scope + val scope = c.trace.get(BindingContext.LEXICAL_SCOPE, annotationEntry) + ?: (c.scope.ownerDescriptor as? PackageFragmentDescriptor)?.let { + LexicalScope.Base(c.scope, FileDescriptorForVisibilityChecks(source, it)) + } ?: c.scope val resolutionResults = c.annotationResolver.resolveAnnotationCall(annotationEntry, scope, c.trace) AnnotationResolverImpl.checkAnnotationType(annotationEntry, c.trace, resolutionResults)