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:
@@ -0,0 +1,18 @@
|
||||
const val aConst = 1
|
||||
const val bConst = aConst + 1
|
||||
|
||||
const val boolVal = bConst > 1 || (B.boolVal && A.boolVal)
|
||||
const val stringInterpolation = "Result: ${B.boolVal}"
|
||||
|
||||
object A {
|
||||
const val boolVal = bConst + 3 == 5
|
||||
|
||||
const val recursive1: Int = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>1 + B.recursive2<!>
|
||||
}
|
||||
|
||||
class B {
|
||||
companion object {
|
||||
const val boolVal = A.boolVal
|
||||
const val recursive2: Int = <!CONST_VAL_WITH_NON_CONST_INITIALIZER!>A.recursive1 + 2<!>
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user