KT-7897 Do not require to call enum constructor for each entry if all parameters have default values
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
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user