mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-16 00:21:32 +00:00
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
19 lines
489 B
Kotlin
Vendored
19 lines
489 B
Kotlin
Vendored
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<!>
|
|
}
|
|
}
|