AA: introduce KtConstantEvaluationMode

This commit is contained in:
Jinseong Jeon
2022-03-10 00:16:14 -08:00
committed by Ilya Kirillov
parent ee23a52e54
commit 606033e1e6
58 changed files with 350 additions and 63 deletions
@@ -0,0 +1,3 @@
expression: 42 / d
constant: 42
constantValueKind: Int
@@ -0,0 +1,4 @@
class Test {
val p = <expr>42 / d</expr> // uninitialized d
const val d = 1
}
@@ -0,0 +1,3 @@
expression: 42 / d
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
@@ -0,0 +1,3 @@
expression: 42 / d
constant: error("Division by zero")
constantValueKind: Error
@@ -0,0 +1,5 @@
class Test {
val p = <expr>42 / d</expr> // uninitialized d
val d = 0 // should not raise div-by-zero error
}
@@ -0,0 +1,3 @@
expression: 42 / d
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
@@ -0,0 +1,8 @@
class Test {
const val bar : Int = 42
}
fun box() {
val t = Test()
t.<expr>bar</expr>
}
@@ -0,0 +1,8 @@
class Test {
val bar : Int = 42
}
fun box() {
val t = Test()
t.<expr>bar</expr>
}
@@ -0,0 +1,3 @@
expression: bar
constant: 42
constantValueKind: Int
@@ -0,0 +1,3 @@
expression: bar
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
@@ -0,0 +1,3 @@
expression: 42 / d
constant: 42
constantValueKind: Int
@@ -0,0 +1,2 @@
const val d = 1
val p = <expr>42 / d</expr>
@@ -0,0 +1,3 @@
expression: 42 / d
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED
@@ -0,0 +1,3 @@
expression: 42 / d
constant: 42
constantValueKind: Int
@@ -0,0 +1,2 @@
val d = 1
val p = <expr>42 / d</expr>
@@ -0,0 +1,3 @@
expression: 42 / d
constant: NOT_EVALUATED
constantValueKind: NOT_EVALUATED