Deserialize constructors of static nested classes correctly

Similar to what is done in TopDownAnalyzer
 #KT-4081 Fixed
This commit is contained in:
Alexander Udalov
2013-10-15 19:17:43 +04:00
parent d5bd8eebff
commit 6e45533065
6 changed files with 30 additions and 5 deletions
@@ -290,6 +290,13 @@ public class CodegenUtil {
//TODO: It's best to use this code also for compilation against sources //TODO: It's best to use this code also for compilation against sources
// but sometimes structures that have expectedThisObject (bug?) mapped to static classes // but sometimes structures that have expectedThisObject (bug?) mapped to static classes
ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject(); ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject();
return expectedThisObject != null ? (ClassDescriptor) expectedThisObject.getContainingDeclaration() : null; if (expectedThisObject != null) {
ClassDescriptor expectedThisClass = (ClassDescriptor) expectedThisObject.getContainingDeclaration();
if (!expectedThisClass.getKind().isObject()) {
return expectedThisClass;
}
}
return null;
} }
} }
@@ -25,11 +25,11 @@ import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.descriptors.impl.*; import org.jetbrains.jet.lang.descriptors.impl.*;
import org.jetbrains.jet.lang.resolve.DescriptorFactory; import org.jetbrains.jet.lang.resolve.DescriptorFactory;
import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.storage.StorageManager;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe; import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.ErrorUtils; import org.jetbrains.jet.lang.types.ErrorUtils;
import org.jetbrains.jet.lang.types.Variance; import org.jetbrains.jet.lang.types.Variance;
import org.jetbrains.jet.storage.StorageManager;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@@ -267,7 +267,7 @@ public class DescriptorDeserializer {
classDescriptor.getTypeConstructor().getParameters(), classDescriptor.getTypeConstructor().getParameters(),
local.valueParameters(proto.getValueParameterList()), local.valueParameters(proto.getValueParameterList()),
visibility(Flags.VISIBILITY.get(proto.getFlags())), visibility(Flags.VISIBILITY.get(proto.getFlags())),
!classDescriptor.isInner() DescriptorUtils.isConstructorOfStaticNestedClass(descriptor)
); );
descriptor.setReturnType(local.typeDeserializer.type(proto.getReturnType())); descriptor.setReturnType(local.typeDeserializer.type(proto.getReturnType()));
return descriptor; return descriptor;
@@ -0,0 +1,5 @@
package a
object CartRoutes {
class RemoveOrderItem()
}
@@ -0,0 +1,5 @@
import a.CartRoutes
fun main(args: Array<String>) {
val r = CartRoutes.RemoveOrderItem()
}
@@ -16,14 +16,17 @@
package org.jetbrains.jet.codegen; package org.jetbrains.jet.codegen;
import junit.framework.Assert;
import junit.framework.Test; import junit.framework.Test;
import junit.framework.TestSuite; import junit.framework.TestSuite;
import java.io.File;
import java.util.regex.Pattern;
import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.InnerTestClasses; import org.jetbrains.jet.test.InnerTestClasses;
import org.jetbrains.jet.test.TestMetadata; import org.jetbrains.jet.test.TestMetadata;
import java.io.File; import org.jetbrains.jet.codegen.AbstractBytecodeTextTest;
import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */ /** This class is generated by {@link org.jetbrains.jet.generators.tests.GenerateTests}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all") @SuppressWarnings("all")
@@ -36,6 +36,11 @@ public class CompileKotlinAgainstKotlinTestGenerated extends AbstractCompileKotl
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/compileKotlinAgainstKotlin"), Pattern.compile("^(.+)\\.A.kt$"), true); JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/compileKotlinAgainstKotlin"), Pattern.compile("^(.+)\\.A.kt$"), true);
} }
@TestMetadata("ClassInObject.A.kt")
public void testClassInObject() throws Exception {
doTest("compiler/testData/compileKotlinAgainstKotlin/ClassInObject.A.kt");
}
@TestMetadata("ClassObjectMember.A.kt") @TestMetadata("ClassObjectMember.A.kt")
public void testClassObjectMember() throws Exception { public void testClassObjectMember() throws Exception {
doTest("compiler/testData/compileKotlinAgainstKotlin/ClassObjectMember.A.kt"); doTest("compiler/testData/compileKotlinAgainstKotlin/ClassObjectMember.A.kt");