KT-4485 getGenericInterfaces vs getInterfaces for kotlin classes
#KT-4485 fixed
This commit is contained in:
@@ -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"
|
||||
}
|
||||
+5
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user