Don't make traits and annotations inherit from KObject
#KT-5609 Fixed
This commit is contained in:
@@ -65,7 +65,6 @@ import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lang.types.checker.JetTypeChecker;
|
||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.renderer.DescriptorRenderer;
|
||||
import org.jetbrains.org.objectweb.asm.*;
|
||||
import org.jetbrains.org.objectweb.asm.commons.InstructionAdapter;
|
||||
import org.jetbrains.org.objectweb.asm.commons.Method;
|
||||
@@ -369,7 +368,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
LinkedHashSet<String> superInterfaces = new LinkedHashSet<String>();
|
||||
if (!explicitKObject) {
|
||||
if (!explicitKObject && !isInterface(descriptor)) {
|
||||
Type kObject = asmTypeByFqNameWithoutInnerClasses(JvmAbi.K_OBJECT);
|
||||
sw.writeInterface();
|
||||
sw.writeClassBegin(kObject);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
public interface Generic <N, NN> extends kotlin.jvm.internal.KObject {
|
||||
public interface Generic <N, NN> {
|
||||
N a(@jet.runtime.typeinfo.JetValueParameter(name = "n") N n);
|
||||
|
||||
@org.jetbrains.annotations.NotNull
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
public interface Primitives extends kotlin.jvm.internal.KObject {
|
||||
public interface Primitives {
|
||||
int $$int /* Real name is 'int' */(@jet.runtime.typeinfo.JetValueParameter(name = "x") int x);
|
||||
|
||||
@org.jetbrains.annotations.Nullable
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
public interface PrivateInTrait extends kotlin.jvm.internal.KObject {
|
||||
public interface PrivateInTrait {
|
||||
@org.jetbrains.annotations.NotNull
|
||||
java.lang.String getNn();
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
public interface Trait extends kotlin.jvm.internal.KObject {
|
||||
public interface Trait {
|
||||
@org.jetbrains.annotations.NotNull
|
||||
java.lang.String notNull(@jet.runtime.typeinfo.JetValueParameter(name = "a") @org.jetbrains.annotations.NotNull java.lang.String a);
|
||||
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
public interface TraitClassObjectField extends kotlin.jvm.internal.KObject {
|
||||
public interface TraitClassObjectField {
|
||||
TraitClassObjectField.object OBJECT$;
|
||||
@org.jetbrains.annotations.Nullable
|
||||
java.lang.String x = "";
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// KT-5609: interfaces should not inherit from KObject, unless explicitly said so
|
||||
|
||||
trait A
|
||||
|
||||
trait B : kotlin.jvm.internal.KObject
|
||||
|
||||
annotation class C
|
||||
|
||||
class D
|
||||
|
||||
class E : kotlin.jvm.internal.KObject
|
||||
|
||||
fun box(): String {
|
||||
val a = javaClass<A>().getGenericInterfaces().toList()
|
||||
if (a.toString() != "[]") return "Fail A: $a"
|
||||
|
||||
val b = javaClass<B>().getGenericInterfaces().toList()
|
||||
if (b.toString() != "[interface kotlin.jvm.internal.KObject]") return "Fail B: $b"
|
||||
|
||||
val c = javaClass<C>().getGenericInterfaces().toList()
|
||||
if (c.toString() != "[interface java.lang.annotation.Annotation]") return "Fail C: $c"
|
||||
|
||||
val d = javaClass<D>().getGenericInterfaces().toList()
|
||||
if (d.toString() != "[interface kotlin.jvm.internal.KObject]") return "Fail D: $d"
|
||||
|
||||
val e = javaClass<E>().getGenericInterfaces().toList()
|
||||
if (e.toString() != "[interface kotlin.jvm.internal.KObject]") return "Fail E: $e"
|
||||
|
||||
return "OK"
|
||||
}
|
||||
+1
-1
@@ -3,4 +3,4 @@ trait Derived<A>: List<A>
|
||||
|
||||
// class: Derived
|
||||
// jvm signature: Derived
|
||||
// generic signature: <A:Ljava/lang/Object;>Ljava/lang/Object;Lkotlin/jvm/internal/KObject;Ljava/util/List<TA;>;
|
||||
// generic signature: <A:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/List<TA;>;
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
@@ -233,11 +232,8 @@ public class AnnotationGenTest extends CodegenTestCase {
|
||||
Class[] interfaces = aClass.getInterfaces();
|
||||
assertEquals(0, aClass.getDeclaredMethods().length);
|
||||
assertTrue(aClass.isAnnotation());
|
||||
assertEquals(2, interfaces.length);
|
||||
assertEquals(
|
||||
Sets.newHashSet("java.lang.annotation.Annotation", "kotlin.jvm.internal.KObject"),
|
||||
Sets.newHashSet(interfaces[0].getName(), interfaces[1].getName())
|
||||
);
|
||||
assertEquals(1, interfaces.length);
|
||||
assertEquals("java.lang.annotation.Annotation", interfaces[0].getName());
|
||||
}
|
||||
|
||||
public void testAnnotationClassWithStringProperty()
|
||||
|
||||
+5
@@ -1843,6 +1843,11 @@ public class BlackBoxWithStdlibCodegenTestGenerated extends AbstractBlackBoxCode
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/kt533.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt5609.kt")
|
||||
public void testKt5609() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/kt5609.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt715.kt")
|
||||
public void testKt715() throws Exception {
|
||||
doTestWithStdlib("compiler/testData/codegen/boxWithStdlib/regressions/kt715.kt");
|
||||
|
||||
Reference in New Issue
Block a user