mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-17 15:54:03 +00:00
Do not report an error on enum entry without initializer if all parameters have default values (error is still reported if there is no such constructor, or if the constructor call is ambiguous). Record resolved call on KtEnumEntry. NB is the enum entry has a corresponding subclass, we still have to generate the "default" constructor call, because FE doesn't know about the platform-specific representation of that class and its constructors. See also KT-14097, KT-15900
44 lines
663 B
Kotlin
Vendored
44 lines
663 B
Kotlin
Vendored
// WITH_RUNTIME
|
|
|
|
enum class TestEnum1 {
|
|
TEST1, TEST2
|
|
}
|
|
|
|
enum class TestEnum2(val x: Int) {
|
|
TEST1(1),
|
|
TEST2(2),
|
|
TEST3(3) {}
|
|
}
|
|
|
|
enum class TestEnum3 {
|
|
TEST {
|
|
override fun foo() {
|
|
println("Hello, world!")
|
|
}
|
|
}
|
|
;
|
|
abstract fun foo()
|
|
}
|
|
|
|
enum class TestEnum4(val x: Int) {
|
|
TEST1(1) {
|
|
override fun foo() {
|
|
println(TEST1)
|
|
}
|
|
},
|
|
TEST2(2) {
|
|
val z: Int
|
|
init {
|
|
z = x
|
|
}
|
|
override fun foo() {
|
|
println(TEST2)
|
|
}
|
|
}
|
|
;
|
|
abstract fun foo()
|
|
}
|
|
|
|
enum class TestEnum5(val x: Int = 0) {
|
|
TEST1, TEST2(), TEST3(0)
|
|
} |