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,45 @@
|
||||
class Test {
|
||||
private val foo = Example.FOO
|
||||
|
||||
companion object {
|
||||
enum class Example { FOO }
|
||||
}
|
||||
}
|
||||
|
||||
class Test2 {
|
||||
private val foo = Example.FOO
|
||||
|
||||
companion object Amigo {
|
||||
enum class Example { FOO }
|
||||
}
|
||||
}
|
||||
|
||||
class Test3 {
|
||||
private val foo = Amigo.Example.FOO
|
||||
|
||||
object Amigo {
|
||||
enum class Example { FOO }
|
||||
}
|
||||
}
|
||||
|
||||
class Test4 {
|
||||
private val foo = Foo.constProperty
|
||||
|
||||
companion object {
|
||||
object Foo {
|
||||
const val constProperty = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Test5 {
|
||||
private val foo = Amigos.Companion.Goo.Example.FOO
|
||||
|
||||
class Amigos {
|
||||
companion object {
|
||||
class Goo {
|
||||
enum class Example { FOO }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user