LR: Class objects are only allowed in a static context
This commit is contained in:
@@ -333,4 +333,20 @@ public class DescriptorUtils {
|
||||
public static boolean isNotAny(@NotNull DeclarationDescriptor superClassDescriptor) {
|
||||
return !superClassDescriptor.equals(JetStandardClasses.getAny());
|
||||
}
|
||||
|
||||
public static boolean inStaticContext(@NotNull DeclarationDescriptor descriptor) {
|
||||
DeclarationDescriptor containingDeclaration = descriptor.getContainingDeclaration();
|
||||
if (containingDeclaration instanceof NamespaceDescriptor) {
|
||||
return true;
|
||||
}
|
||||
if (containingDeclaration instanceof ClassDescriptor) {
|
||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||
|
||||
if (classDescriptor.getKind() == ClassKind.OBJECT) {
|
||||
return inStaticContext(classDescriptor.getContainingDeclaration());
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -225,6 +225,9 @@ public class LazyClassDescriptor extends ClassDescriptorBase implements ClassDes
|
||||
@Nullable
|
||||
private JetClassLikeInfo getClassObjectInfo(JetClassObject classObject) {
|
||||
if (classObject != null) {
|
||||
if (!DescriptorUtils.inStaticContext(this)) {
|
||||
return null;
|
||||
}
|
||||
JetObjectDeclaration objectDeclaration = classObject.getObjectDeclaration();
|
||||
if (objectDeclaration != null) {
|
||||
return JetClassInfoUtil.createClassLikeInfo(objectDeclaration);
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
namespace <root>
|
||||
|
||||
internal final class A : jet.Any {
|
||||
public final /*constructor*/ fun <init>(): A
|
||||
internal final class A.B : jet.Any {
|
||||
public final /*constructor*/ fun <init>(): A.B
|
||||
}
|
||||
}
|
||||
internal final class B : jet.Any {
|
||||
public final /*constructor*/ fun <init>(): B
|
||||
internal final class object B.<no name provided> : jet.Any {
|
||||
internal final /*constructor*/ fun <init>(): B.<no name provided>
|
||||
internal final class B.<no name provided>.B : jet.Any {
|
||||
public final /*constructor*/ fun <init>(): B.<no name provided>.B
|
||||
internal final class object B.<no name provided>.B.<no name provided> : jet.Any {
|
||||
internal final /*constructor*/ fun <init>(): B.<no name provided>.B.<no name provided>
|
||||
internal final class B.<no name provided>.B.<no name provided>.C : jet.Any {
|
||||
public final /*constructor*/ fun <init>(): B.<no name provided>.B.<no name provided>.C
|
||||
internal final class object B.<no name provided>.B.<no name provided>.C.<no name provided> : jet.Any {
|
||||
internal final /*constructor*/ fun <init>(): B.<no name provided>.B.<no name provided>.C.<no name provided>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user