Add checks for const modifier applicability
1. Must be initialized in-place 2. Can not be open/abstract 3. Can not be an override 4. Can not be delegated 5. Initializer must be a compile-time constant 6. No getters 7. `const` is not applicable to vars or locals 8. `const val` should be whether top-level property or object member
This commit is contained in:
@@ -36,6 +36,7 @@ class IllegalModifiers1(
|
||||
<!WRONG_MODIFIER_TARGET!>reified<!>
|
||||
<!WRONG_MODIFIER_TARGET!>enum<!>
|
||||
<!WRONG_MODIFIER_TARGET!>private<!>
|
||||
<!WRONG_MODIFIER_TARGET!>const<!>
|
||||
<!UNUSED_PARAMETER!>a<!>: Int)
|
||||
|
||||
//Check multiple illegal modifiers in constructor
|
||||
@@ -110,6 +111,7 @@ class IllegalModifiers7() {
|
||||
<!INCOMPATIBLE_MODIFIERS!>in<!>
|
||||
<!WRONG_MODIFIER_TARGET!>vararg<!>
|
||||
<!WRONG_MODIFIER_TARGET!>reified<!>
|
||||
<!WRONG_MODIFIER_TARGET!>const<!>
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
@@ -126,6 +128,7 @@ class IllegalModifiers8 {
|
||||
<!INCOMPATIBLE_MODIFIERS!>final<!>
|
||||
<!WRONG_MODIFIER_TARGET!>vararg<!>
|
||||
<!WRONG_MODIFIER_TARGET!>reified<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>const<!>
|
||||
constructor() {}
|
||||
|
||||
constructor(<!WRONG_MODIFIER_TARGET!>private<!> <!WRONG_MODIFIER_TARGET!>enum<!> <!WRONG_MODIFIER_TARGET!>abstract<!> <!UNUSED_PARAMETER!>x<!>: Int) {}
|
||||
@@ -149,6 +152,7 @@ class IllegalModifiers10
|
||||
<!INCOMPATIBLE_MODIFIERS!>in<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>final<!>
|
||||
<!WRONG_MODIFIER_TARGET!>vararg<!>
|
||||
<!WRONG_MODIFIER_TARGET!>reified<!> constructor()
|
||||
<!WRONG_MODIFIER_TARGET!>reified<!>
|
||||
<!INCOMPATIBLE_MODIFIERS!>const<!> constructor()
|
||||
|
||||
class IllegalModifiers11 <!INCOMPATIBLE_MODIFIERS!>private<!> <!INCOMPATIBLE_MODIFIERS!>protected<!> constructor()
|
||||
|
||||
Reference in New Issue
Block a user