ee9a174c1f
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
21 lines
508 B
Kotlin
Vendored
21 lines
508 B
Kotlin
Vendored
enum class TestOk(val x: String = "OK") {
|
|
TEST1,
|
|
TEST2(),
|
|
TEST3("Hello")
|
|
}
|
|
|
|
enum class TestErrors(val x: String) {
|
|
<!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>TEST1,<!>
|
|
TEST2(<!NO_VALUE_FOR_PARAMETER!>)<!>,
|
|
TEST3("Hello")
|
|
}
|
|
|
|
enum class TestMultipleConstructors(val x: String = "", val y: Int = 0) {
|
|
<!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>TEST;<!>
|
|
constructor(x: String = "") : this(x, 0)
|
|
}
|
|
|
|
enum class TestVarargs(val x: Int) {
|
|
TEST;
|
|
constructor(vararg xs: Any) : this(xs.size)
|
|
} |