Allow to create object in interpreter only if it is compile time

This commit is contained in:
Ivan Kylchik
2021-05-24 16:21:37 +03:00
committed by TeamCityServer
parent 6e12cee626
commit 25989b36c5
3 changed files with 13 additions and 5 deletions
+5
View File
@@ -1,3 +1,4 @@
@CompileTimeCalculation
class A {
const val a = <!EVALUATED: `10`!>{ 10 }()<!>
@@ -10,10 +11,13 @@ class A {
}
}
@CompileTimeCalculation
object ObjectWithConst {
const val a = 100
const val b = <!EVALUATED: `Value in a: 100`!>concat("Value in a: ", a)<!>
val nonConst = "Not const field in compile time object"
fun concat(first: String, second: Any) = "$first$second"
}
@@ -21,3 +25,4 @@ const val num = A().<!EVALUATED: `10`!>a<!>
const val numStatic = A.<!EVALUATED: `-10`!>static<!>
const val numStaticFromFun = A.<!EVALUATED: `2147483647`!>getStaticNumber()<!>
const val valFromObject = ObjectWithConst.<!EVALUATED: `Value in a: 100`!>b<!>
const val valFnonConstFromObject = ObjectWithConst.<!EVALUATED: `Not const field in compile time object`!>nonConst<!>