Allow to create object in interpreter only if it is compile time
This commit is contained in:
committed by
TeamCityServer
parent
6e12cee626
commit
25989b36c5
+5
@@ -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<!>
|
||||
|
||||
Reference in New Issue
Block a user