LTDA: Move prohibited 'class object' to the list with extra class objects descriptors in lazy resolve
This commit is contained in:
+15
-3
@@ -162,7 +162,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Function0<LazyClassDescriptor>() {
|
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Function0<LazyClassDescriptor>() {
|
||||||
@Override
|
@Override
|
||||||
public LazyClassDescriptor invoke() {
|
public LazyClassDescriptor invoke() {
|
||||||
return computeClassObjectDescriptor(declarationProvider.getOwnerInfo().getClassObject());
|
return computeClassObjectDescriptor(getClassObjectIfAllowed());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.extraClassObjectDescriptors = storageManager.createMemoizedFunction(new Function1<JetClassObject, ClassDescriptor>() {
|
this.extraClassObjectDescriptors = storageManager.createMemoizedFunction(new Function1<JetClassObject, ClassDescriptor>() {
|
||||||
@@ -334,13 +334,15 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
@NotNull
|
@NotNull
|
||||||
@ReadOnly
|
@ReadOnly
|
||||||
public List<ClassDescriptor> getDescriptorsForExtraClassObjects() {
|
public List<ClassDescriptor> getDescriptorsForExtraClassObjects() {
|
||||||
|
final JetClassObject allowedClassObject = getClassObjectIfAllowed();
|
||||||
|
|
||||||
return KotlinPackage.map(
|
return KotlinPackage.map(
|
||||||
KotlinPackage.filter(
|
KotlinPackage.filter(
|
||||||
declarationProvider.getOwnerInfo().getClassObjects(),
|
declarationProvider.getOwnerInfo().getClassObjects(),
|
||||||
new Function1<JetClassObject, Boolean>() {
|
new Function1<JetClassObject, Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean invoke(JetClassObject classObject) {
|
public Boolean invoke(JetClassObject classObject) {
|
||||||
return classObject != declarationProvider.getOwnerInfo().getClassObject();
|
return classObject != allowedClassObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
),
|
),
|
||||||
@@ -365,7 +367,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
@Nullable
|
@Nullable
|
||||||
private JetClassLikeInfo getClassObjectInfo(@Nullable JetClassObject classObject) {
|
private JetClassLikeInfo getClassObjectInfo(@Nullable JetClassObject classObject) {
|
||||||
if (classObject != null) {
|
if (classObject != null) {
|
||||||
if (getKind().isSingleton() || isInner()) {
|
if (!isClassObjectAllowed()) {
|
||||||
resolveSession.getTrace().report(CLASS_OBJECT_NOT_ALLOWED.on(classObject));
|
resolveSession.getTrace().report(CLASS_OBJECT_NOT_ALLOWED.on(classObject));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,6 +380,16 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private JetClassObject getClassObjectIfAllowed() {
|
||||||
|
JetClassObject classObject = declarationProvider.getOwnerInfo().getClassObject();
|
||||||
|
return (classObject != null && isClassObjectAllowed()) ? classObject : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isClassObjectAllowed() {
|
||||||
|
return !(getKind().isSingleton() || isInner());
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ClassKind getKind() {
|
public ClassKind getKind() {
|
||||||
|
|||||||
Reference in New Issue
Block a user