Kapt: Don't convert field initializers for enum fields inside companion objects (KT-37732)
For classes with companion objects, Kotlin compiler generates a 'Companion' static accessor field. Java prioritizes fields over inner types (apparently, Scala does this as well, KT-29864), so the generated initializer doesn't compile. As a workaround, initializer generatation is disabled for enum fields inside companion objects. Certainly, it's not a proper fix, however it does fix the regression.
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class Test {
|
||||
private final Test.Companion.Example foo;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final Test.Companion Companion = null;
|
||||
|
||||
public Test() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static final class Companion {
|
||||
|
||||
private Companion() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static enum Example {
|
||||
/*public static final*/ FOO /* = new Example() */;
|
||||
|
||||
Example() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class Test2 {
|
||||
private final Test2.Amigo.Example foo;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final Test2.Amigo Amigo = null;
|
||||
|
||||
public Test2() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static final class Amigo {
|
||||
|
||||
private Amigo() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static enum Example {
|
||||
/*public static final*/ FOO /* = new Example() */;
|
||||
|
||||
Example() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class Test3 {
|
||||
private final Test3.Amigo.Example foo = Test3.Amigo.Example.FOO;
|
||||
|
||||
public Test3() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static final class Amigo {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final Test3.Amigo INSTANCE = null;
|
||||
|
||||
private Amigo() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static enum Example {
|
||||
/*public static final*/ FOO /* = new Example() */;
|
||||
|
||||
Example() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class Test4 {
|
||||
private final int foo = 1;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final Test4.Companion Companion = null;
|
||||
|
||||
public Test4() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static final class Companion {
|
||||
|
||||
private Companion() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static final class Foo {
|
||||
public static final int constProperty = 1;
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final Test4.Companion.Foo INSTANCE = null;
|
||||
|
||||
private Foo() {
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////
|
||||
|
||||
|
||||
import java.lang.System;
|
||||
|
||||
@kotlin.Metadata()
|
||||
public final class Test5 {
|
||||
private final Test5.Amigos.Companion.Goo.Example foo;
|
||||
|
||||
public Test5() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static final class Amigos {
|
||||
@org.jetbrains.annotations.NotNull()
|
||||
public static final Test5.Amigos.Companion Companion = null;
|
||||
|
||||
public Amigos() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static final class Companion {
|
||||
|
||||
private Companion() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static final class Goo {
|
||||
|
||||
public Goo() {
|
||||
super();
|
||||
}
|
||||
|
||||
@kotlin.Metadata()
|
||||
public static enum Example {
|
||||
/*public static final*/ FOO /* = new Example() */;
|
||||
|
||||
Example() {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user