diff options
author | Vladimir Dolzhenko <vladimir.dolzhenko@jetbrains.com> | 2022-11-22 12:17:24 +0100 |
---|---|---|
committer | Matthew Gharrity <gharrma@google.com> | 2022-11-28 11:46:12 -0800 |
commit | d587ea4db3f1920ab5772c2496879e842228f296 (patch) | |
tree | ebb01fc2cf95298adf382936c963c5cf38229770 | |
parent | 717ee56fc4c283f1037fdbc3379135d380578da4 (diff) | |
download | kotlin-studio-main.tar.gz |
Prevent unsafe publication of not full initialized instancestudio-2023.3.1-canary03studio-2023.2.1-rc1studio-2023.2.1-canary05studio-2023.2.1-beta02studio-2023.2.1studio-2023.1.1-patch2studio-2023.1.1-patch1studio-2023.1.1-canary3studio-2023.1.1-canary11studio-2023.1.1-beta05studio-2023.1.1studio-2022.3.1-rc1studio-2022.3.1-canary8studio-2022.3.1-canary1studio-2022.3.1-beta2studio-2022.3.1studio-main
KTIJ-22182
(cherry picked from commit a8bef8ac816c2e5e9a371c32fdf1ae31ac113aca)
Bug: 258691752
Change-Id: Ic62ce2a84b39982b21e58c653ad2dc661808197b
-rw-r--r-- | compiler/frontend/src/org/jetbrains/kotlin/resolve/AnnotationResolverImpl.java | 5 | ||||
-rw-r--r-- | compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyAnnotations.kt | 10 |
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 |