LTDA: Move prohibited 'class object' to the list with extra class objects descriptors in lazy resolve

This commit is contained in:
Nikolay Krasko
2014-09-11 18:18:03 +04:00
parent a2ddaeca77
commit 5657d30125
@@ -162,7 +162,7 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
this.classObjectDescriptor = storageManager.createNullableLazyValue(new Function0<LazyClassDescriptor>() {
@Override
public LazyClassDescriptor invoke() {
return computeClassObjectDescriptor(declarationProvider.getOwnerInfo().getClassObject());
return computeClassObjectDescriptor(getClassObjectIfAllowed());
}
});
this.extraClassObjectDescriptors = storageManager.createMemoizedFunction(new Function1<JetClassObject, ClassDescriptor>() {
@@ -334,13 +334,15 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
@NotNull
@ReadOnly
public List<ClassDescriptor> getDescriptorsForExtraClassObjects() {
final JetClassObject allowedClassObject = getClassObjectIfAllowed();
return KotlinPackage.map(
KotlinPackage.filter(
declarationProvider.getOwnerInfo().getClassObjects(),
new Function1<JetClassObject, Boolean>() {
@Override
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
private JetClassLikeInfo getClassObjectInfo(@Nullable JetClassObject classObject) {
if (classObject != null) {
if (getKind().isSingleton() || isInner()) {
if (!isClassObjectAllowed()) {
resolveSession.getTrace().report(CLASS_OBJECT_NOT_ALLOWED.on(classObject));
}
@@ -378,6 +380,16 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
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
@Override
public ClassKind getKind() {