Introduce warning for secondary constructor in enums without delegation to primary constructors (KT-35870)

This commit is contained in:
Victor Petukhov
2020-09-25 11:50:35 +03:00
parent 416874f9d0
commit 63d825fa24
13 changed files with 626 additions and 15 deletions
@@ -0,0 +1,43 @@
// DIAGNOSTICS: -UNUSED_PARAMETER
// !LANGUAGE: -RequiredPrimaryConstructorDelegationCallInEnums
enum class Enum1(val a: String) {
A;
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED_IN_ENUM!>constructor()<!>
}
enum class Enum2(val a: String) {
A, B;
constructor(): this("")
}
enum class Enum3(val a: String = "") {
<!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>A,<!> <!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>B,<!> <!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>C;<!>
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED_IN_ENUM!>constructor()<!>
}
enum class Enum4(val a: String = "") {
<!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>A,<!> <!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>B,<!> <!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>C;<!>
constructor(): <!CYCLIC_CONSTRUCTOR_DELEGATION_CALL!>this<!>()
}
enum class Enum5(val a: String = "") {
<!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>A,<!> <!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>B,<!> <!ENUM_ENTRY_SHOULD_BE_INITIALIZED!>C;<!>
constructor(): this(a = "")
}
enum class Enum6(val a: String = "") {
A, B, C;
}
enum class Enum7(val a: String) {
A, B, C;
constructor(): this(10)
constructor(x: Int): this("")
}
enum class Enum8(val a: String) {
A, B, C;
constructor(): this(10)
<!PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED_IN_ENUM!>constructor(x: Int)<!>
}