From 79b895481440c9b4e48d4333f781f3af526bd991 Mon Sep 17 00:00:00 2001 From: Vladimir Dolzhenko Date: Thu, 8 Dec 2022 15:19:18 +0100 Subject: [PATCH] Prevent unsafe publication of not fully initialized instance #KT-54085 Fixed #EA-757831 --- .../resolve/lazy/descriptors/LazyClassDescriptor.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java index 96b4f999c01..081b9d18bab 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/lazy/descriptors/LazyClassDescriptor.java @@ -122,10 +122,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes this.c = c; classOrObject = classLikeInfo.getCorrespondingClassOrObject(); - if (classOrObject != null) { - this.c.getTrace().record(BindingContext.CLASS, classOrObject, this); - } - this.c.getTrace().record(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, DescriptorUtils.getFqName(this), this); this.declarationProvider = c.getDeclarationProviderFactory().getClassMemberDeclarationProvider(classLikeInfo); @@ -345,6 +341,11 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes return contextReceiverDescriptors; }); + + if (classOrObject != null) { + this.c.getTrace().record(BindingContext.CLASS, classOrObject, this); + } + this.c.getTrace().record(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, DescriptorUtils.getFqName(this), this); } private static boolean isIllegalInner(@NotNull DeclarationDescriptor descriptor) {