KT-2784 VerifyError when passing a value to a class object's super type constructor
#KT-2784 Fixed
This commit is contained in:
@@ -90,11 +90,9 @@ public class CodegenUtil {
|
||||
}
|
||||
|
||||
public static boolean isNonLiteralObject(JetClassOrObject myClass) {
|
||||
return myClass instanceof JetObjectDeclaration && !((JetObjectDeclaration) myClass).isObjectLiteral() &&
|
||||
!(myClass.getParent() instanceof JetClassObject);
|
||||
return myClass instanceof JetObjectDeclaration && !((JetObjectDeclaration) myClass).isObjectLiteral();
|
||||
}
|
||||
|
||||
|
||||
public static String createTmpVariableName(Collection<String> existingNames) {
|
||||
String prefix = "tmp";
|
||||
int i = RANDOM.nextInt(Integer.MAX_VALUE);
|
||||
|
||||
@@ -936,8 +936,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
private void generateFieldForSingleton() {
|
||||
boolean hasClassObject = descriptor.getClassObjectDescriptor() != null;
|
||||
boolean isEnumClass = DescriptorUtils.isEnumClass(descriptor);
|
||||
boolean isObjectDeclaration = descriptor.getKind() == ClassKind.OBJECT && isNonLiteralObject(myClass) ;
|
||||
|
||||
if (!(isNonLiteralObject(myClass) || hasClassObject) || isEnumClass) return;
|
||||
if (!isObjectDeclaration && !hasClassObject || isEnumClass) return;
|
||||
|
||||
ClassDescriptor fieldTypeDescriptor = hasClassObject ? descriptor.getClassObjectDescriptor() : descriptor;
|
||||
assert fieldTypeDescriptor != null;
|
||||
|
||||
@@ -187,16 +187,11 @@ public class CodegenBinding {
|
||||
}
|
||||
|
||||
public static boolean isSingleton(BindingContext bindingContext, @NotNull ClassDescriptor classDescriptor) {
|
||||
ClassKind kind = classDescriptor.getKind();
|
||||
if (kind == ClassKind.CLASS_OBJECT) {
|
||||
if (isObjectDeclaration(bindingContext, classDescriptor)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kind == ClassKind.OBJECT && isObjectDeclaration(bindingContext, classDescriptor)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (kind == ClassKind.ENUM_ENTRY) {
|
||||
if (classDescriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,7 +173,7 @@ public class JetObjectDeclaration extends JetNamedDeclarationStub<PsiJetObjectSt
|
||||
}
|
||||
|
||||
public boolean isObjectLiteral() {
|
||||
return getNameAsDeclaration() == null;
|
||||
return getParent() instanceof JetObjectLiteralExpression;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
open class Factory(p: Int)
|
||||
|
||||
class A {
|
||||
class object : Factory(1)
|
||||
}
|
||||
|
||||
fun box() : String {
|
||||
A
|
||||
return "OK"
|
||||
}
|
||||
@@ -955,6 +955,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
||||
doTest("compiler/testData/codegen/box/classes/kt2711.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt2784.kt")
|
||||
public void testKt2784() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/classes/kt2784.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt285.kt")
|
||||
public void testKt285() throws Exception {
|
||||
doTest("compiler/testData/codegen/box/classes/kt285.kt");
|
||||
|
||||
Reference in New Issue
Block a user