KT-5112 Generic signature lost for a field copied from class object to containing class

#KT-5112 Fixed
This commit is contained in:
Mikhael Bogdanov
2014-06-02 13:11:45 +04:00
parent 4a7d4dffdf
commit c80901bafa
3 changed files with 33 additions and 1 deletions
@@ -1030,7 +1030,8 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
PropertyDescriptor property = info.descriptor;
FieldVisitor fv = v.newField(null, ACC_STATIC | ACC_FINAL | ACC_PUBLIC, context.getFieldName(property, false),
typeMapper.mapType(property).getDescriptor(), null, info.defaultValue);
typeMapper.mapType(property).getDescriptor(), typeMapper.mapFieldSignature(property.getType()),
info.defaultValue);
AnnotationCodegen.forField(fv, typeMapper).genAnnotations(property);
@@ -0,0 +1,26 @@
package test
class G<T>(val s: T) {
}
public trait ErrorsJvmTrait {
class object {
public val param : G<String> = G("STRING")
}
}
public class ErrorsJvmClass {
class object {
public val param : G<String> = G("STRING")
}
}
fun box(): String {
val genericType = javaClass<ErrorsJvmTrait>().getField("param").getGenericType()
if (genericType.toString() != "test.G<java.lang.String>") return "fail1: $genericType"
val genericType2 = javaClass<ErrorsJvmClass>().getField("param").getGenericType()
if (genericType2.toString() != "test.G<java.lang.String>") return "fail1: genericType2"
return "OK"
}
@@ -1222,6 +1222,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithStdlib/reflection"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("kt5112.kt")
public void testKt5112() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/reflection/kt5112.kt");
}
@TestMetadata("compiler/testData/codegen/boxWithStdlib/reflection/insideLambda")
public static class InsideLambda extends AbstractBlackBoxCodegenTest {
public void testAllFilesPresentInInsideLambda() throws Exception {