summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Dolzhenko <vladimir.dolzhenko@jetbrains.com>2022-11-22 12:17:24 +0100
committerMatthew Gharrity <gharrma@google.com>2022-11-28 11:46:12 -0800
commitd587ea4db3f1920ab5772c2496879e842228f296 (patch)
treeebb01fc2cf95298adf382936c963c5cf38229770
parent717ee56fc4c283f1037fdbc3379135d380578da4 (diff)
downloadkotlin-studio-main.tar.gz
KTIJ-22182 (cherry picked from commit a8bef8ac816c2e5e9a371c32fdf1ae31ac113aca) Bug: 258691752 Change-Id: Ic62ce2a84b39982b21e58c653ad2dc661808197b
-rw-r--r--compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolverImpl.java5
-rw-r--r--compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt10
2 files changed, 9 insertions, 6 deletions
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolverImpl.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolverImpl.java
index 4c06d1e0494..2983f618b70 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolverImpl.java
+++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolverImpl.java
@@ -94,7 +94,10 @@ public class AnnotationResolverImpl extends AnnotationResolver {
for (KtAnnotationEntry entryElement : annotationEntryElements) {
AnnotationDescriptor descriptor = trace.get(BindingContext.ANNOTATION, entryElement);
if (descriptor == null) {
- descriptor = new LazyAnnotationDescriptor(new LazyAnnotationsContextImpl(this, storageManager, trace, scope), entryElement);
+ LazyAnnotationDescriptor lazyAnnotationDescriptor =
+ new LazyAnnotationDescriptor(new LazyAnnotationsContextImpl(this, storageManager, trace, scope), entryElement);
+ lazyAnnotationDescriptor.recordToTrace();
+ descriptor = lazyAnnotationDescriptor;
}
if (shouldResolveArguments) {
ForceResolveUtil.forceResolveAllContents(descriptor);
diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt
index f2475e5bc19..ca93870e052 100644
--- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt
+++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt
@@ -61,7 +61,7 @@ class LazyAnnotations(
override fun isEmpty() = annotationEntries.isEmpty()
private val annotation = c.storageManager.createMemoizedFunction { entry: KtAnnotationEntry ->
- c.trace.get(BindingContext.ANNOTATION, entry) ?: LazyAnnotationDescriptor(c, entry)
+ c.trace.get(BindingContext.ANNOTATION, entry) ?: LazyAnnotationDescriptor(c, entry).also { it.recordToTrace() }
}
override fun iterator(): Iterator<AnnotationDescriptor> = annotationEntries.asSequence().map(annotation).iterator()
@@ -79,10 +79,6 @@ class LazyAnnotationDescriptor(
val annotationEntry: KtAnnotationEntry
) : AnnotationDescriptor, LazyEntity {
- init {
- c.trace.record(BindingContext.ANNOTATION, annotationEntry, this)
- }
-
override val type by c.storageManager.createLazyValue(
computable = lazy@{
val annotationType = c.annotationResolver.resolveAnnotationType(scope, annotationEntry, c.trace)
@@ -127,6 +123,10 @@ class LazyAnnotationDescriptor(
allValueArguments
}
+ fun recordToTrace() {
+ c.trace.record(BindingContext.ANNOTATION, annotationEntry, this)
+ }
+
private class FileDescriptorForVisibilityChecks(
private val source: SourceElement,
private val containingDeclaration: PackageFragmentDescriptor