KT-4485 getGenericInterfaces vs getInterfaces for kotlin classes

#KT-4485 fixed
This commit is contained in:
Evgeny Gerashchenko
2014-01-29 17:57:50 +04:00
parent 0e9875aec3
commit abf352cebd
3 changed files with 33 additions and 0 deletions
@@ -350,6 +350,10 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
sw.writeSuperclassEnd();
LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>();
sw.writeInterface();
sw.writeClassBegin(Type.getObjectType(JvmAbi.JET_OBJECT.getInternalName()));
sw.writeClassEnd();
sw.writeInterfaceEnd();
superInterfaces.add(JvmAbi.JET_OBJECT.getInternalName());
for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
@@ -0,0 +1,24 @@
// KT-4485 getGenericInterfaces vs getInterfaces for kotlin classes
class SimpleClass
class ClassWithNonGenericSuperInterface: Cloneable
class ClassWithGenericSuperInterface: java.util.Comparator<String> {
override fun compare(a: String, b: String): Int = 0
}
fun check(klass: Class<*>) {
val interfaces = klass.getInterfaces().toList()
val genericInterfaces = klass.getGenericInterfaces().toList()
if (interfaces.size != genericInterfaces.size) {
throw AssertionError("interfaces=$interfaces, genericInterfaces=$genericInterfaces")
}
}
fun box(): String {
check(javaClass<SimpleClass>())
check(javaClass<ClassWithNonGenericSuperInterface>())
check(javaClass<ClassWithGenericSuperInterface>())
return "OK"
}
@@ -903,6 +903,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/generic.kt");
}
@TestMetadata("getGenericInterfaces.kt")
public void testGetGenericInterfaces() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/getGenericInterfaces.kt");
}
@TestMetadata("implicitlyCastToHashable.kt")
public void testImplicitlyCastToHashable() throws Exception {
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/implicitlyCastToHashable.kt");