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 c0cf6230ac2..5a87d9a150d 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 @@ -60,7 +60,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 = annotationEntries.asSequence().map(annotation).iterator() @@ -78,10 +78,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) @@ -133,6 +129,10 @@ class LazyAnnotationDescriptor( allValueArguments } + fun recordToTrace() { + c.trace.record(BindingContext.ANNOTATION, annotationEntry, this) + } + private class FileDescriptorForVisibilityChecks( private val source: SourceElement, private val containingDeclaration: PackageFragmentDescriptor