Always create descriptors for class object psi element in lazy resolve
KT-4397 Exception: @NotNull method org/jetbrains/jet/lang/resolve/lazy/ResolveSession.getClassDescriptor must not return null #KT-4397 Fixed
This commit is contained in:
@@ -214,7 +214,8 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
||||
return (ClassDescriptor) declaration;
|
||||
}
|
||||
|
||||
/*package*/ LazyClassDescriptor getClassObjectDescriptor(JetClassObject classObject) {
|
||||
@NotNull
|
||||
/*package*/ LazyClassDescriptor getClassObjectDescriptor(@NotNull JetClassObject classObject) {
|
||||
JetClass aClass = PsiTreeUtil.getParentOfType(classObject, JetClass.class);
|
||||
|
||||
final LazyClassDescriptor parentClassDescriptor;
|
||||
@@ -237,16 +238,18 @@ public class ResolveSession implements KotlinCodeAnalyzer {
|
||||
// It's possible that there are several class objects and another class object is taking part in lazy resolve. We still want to
|
||||
// build descriptors for such class objects.
|
||||
final JetClassLikeInfo classObjectInfo = parentClassDescriptor.getClassObjectInfo(classObject);
|
||||
if (classObjectInfo != null) {
|
||||
final Name name = SpecialNames.getClassObjectName(parentClassDescriptor.getName());
|
||||
return storageManager.compute(new Function0<LazyClassDescriptor>() {
|
||||
@Override
|
||||
public LazyClassDescriptor invoke() {
|
||||
// Create under lock to avoid premature access to published 'this'
|
||||
return new LazyClassDescriptor(ResolveSession.this, parentClassDescriptor, name, classObjectInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
assert classObjectInfo != null :
|
||||
String.format("Failed to find class object info for existent class object declaration: %s",
|
||||
JetPsiUtil.getElementTextWithContext(classObject));
|
||||
|
||||
final Name name = SpecialNames.getClassObjectName(parentClassDescriptor.getName());
|
||||
return storageManager.compute(new Function0<LazyClassDescriptor>() {
|
||||
@Override
|
||||
public LazyClassDescriptor invoke() {
|
||||
// Create under lock to avoid premature access to published 'this'
|
||||
return new LazyClassDescriptor(ResolveSession.this, parentClassDescriptor, name, classObjectInfo);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (LazyClassDescriptor) declaration;
|
||||
|
||||
+1
-3
@@ -258,9 +258,6 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
||||
@Nullable
|
||||
public JetClassLikeInfo getClassObjectInfo(JetClassObject classObject) {
|
||||
if (classObject != null) {
|
||||
if (!DescriptorUtils.inStaticContext(this)) {
|
||||
return null;
|
||||
}
|
||||
JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();
|
||||
if (objectDeclaration != null) {
|
||||
return JetClassInfoUtil.createClassLikeInfo(objectDeclaration);
|
||||
@@ -269,6 +266,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements LazyDesc
|
||||
else if (getKind() == ClassKind.OBJECT || getKind() == ClassKind.ENUM_ENTRY || getKind() == ClassKind.ENUM_CLASS) {
|
||||
return new SyntheticClassObjectInfo(originalClassInfo, this);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user