IrConstTransformer: transform constants also inside call children

This commit is contained in:
Mikhail Glukhikh
2021-12-10 15:08:43 +03:00
parent 66231baa06
commit febf336d23
9 changed files with 18 additions and 9 deletions
@@ -33,7 +33,7 @@ class IrConstTransformer(private val interpreter: IrInterpreter, private val irF
if (expression.accept(IrCompileTimeChecker(mode = EvaluationMode.ONLY_BUILTINS), null)) {
return interpreter.interpret(expression, irFile).replaceIfError(expression)
}
return expression
return super.visitCall(expression)
}
override fun visitField(declaration: IrField): IrStatement {
@@ -55,5 +55,10 @@ fun box(): String {
Some()
Other()
Another()
run {
@State(name = "A", storages = [(Storage(value = StoragePathMacros.NON_ROAMABLE_FILE))])
class Local
Local()
}
return "OK"
}
@@ -1,4 +1,6 @@
// !LANGUAGE: -InlineConstVals
// IGNORE_BACKEND_FIR: JVM_IR
// FIR status: don't support legacy feature
const val z = 0
@@ -1,4 +1,6 @@
// !LANGUAGE: -InlineConstVals
// IGNORE_BACKEND_FIR: JVM_IR
// FIR status: don't support legacy feature
const val one = 1
const val two = 2
@@ -1,4 +1,6 @@
// !LANGUAGE: -InlineConstVals
// IGNORE_BACKEND_FIR: JVM_IR
// FIR status: don't support legacy feature
const val y = "cde"
@@ -398,8 +398,7 @@ FILE fqName:<root> fileName:/ArrayMap.kt
<T>: T of <root>.ArrayMapImpl
data: CALL 'public final fun arrayOfNulls <T> (size: kotlin.Int): kotlin.Array<T of kotlin.arrayOfNulls?> declared in kotlin' type=kotlin.Array<kotlin.Any?> origin=null
<T>: kotlin.Any
size: CALL 'private final fun <get-DEFAULT_SIZE> (): kotlin.Int declared in <root>.ArrayMapImpl.Companion' type=kotlin.Int origin=GET_PROPERTY
$this: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=<root>.ArrayMapImpl.Companion
size: CONST Int type=kotlin.Int value=20
PROPERTY name:size visibility:public modality:FINAL [var]
overridden:
public abstract size: kotlin.Int [val]
@@ -445,8 +444,7 @@ FILE fqName:<root> fileName:/ArrayMap.kt
$this: CALL 'public final fun <get-size> (): kotlin.Int declared in kotlin.Array' type=kotlin.Int origin=GET_PROPERTY
$this: CALL 'private final fun <get-data> (): kotlin.Array<kotlin.Any?> declared in <root>.ArrayMapImpl' type=kotlin.Array<kotlin.Any?> origin=GET_PROPERTY
$this: GET_VAR '<this>: <root>.ArrayMapImpl<T of <root>.ArrayMapImpl> declared in <root>.ArrayMapImpl.ensureCapacity' type=<root>.ArrayMapImpl<T of <root>.ArrayMapImpl> origin=null
other: CALL 'private final fun <get-INCREASE_K> (): kotlin.Int declared in <root>.ArrayMapImpl.Companion' type=kotlin.Int origin=GET_PROPERTY
$this: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=<root>.ArrayMapImpl.Companion
other: CONST Int type=kotlin.Int value=2
FUN name:set visibility:public modality:FINAL <> ($this:<root>.ArrayMapImpl<T of <root>.ArrayMapImpl>, index:kotlin.Int, value:T of <root>.ArrayMapImpl) returnType:kotlin.Unit [operator]
overridden:
public abstract fun set (index: kotlin.Int, value: T of <root>.ArrayMap): kotlin.Unit [operator] declared in <root>.ArrayMap
@@ -172,7 +172,7 @@ internal class ArrayMapImpl<T : Any> : ArrayMap<T> {
}
constructor() {
this/*ArrayMapImpl*/<T>(data = arrayOfNulls<Any>(size = Companion.<get-DEFAULT_SIZE>()))
this/*ArrayMapImpl*/<T>(data = arrayOfNulls<Any>(size = 20))
}
override var size: Int
@@ -183,7 +183,7 @@ internal class ArrayMapImpl<T : Any> : ArrayMap<T> {
private fun ensureCapacity(index: Int) {
when {
lessOrEqual(arg0 = <this>.<get-data>().<get-size>(), arg1 = index) -> { // BLOCK
<this>.<set-data>(<set-?> = <this>.<get-data>().copyOf<Any?>(newSize = <this>.<get-data>().<get-size>().times(other = Companion.<get-INCREASE_K>())))
<this>.<set-data>(<set-?> = <this>.<get-data>().copyOf<Any?>(newSize = <this>.<get-data>().<get-size>().times(other = 2)))
}
}
}
@@ -64,7 +64,7 @@ FILE fqName:<root> fileName:/coercionToUnitForNestedWhen.kt
BRANCH
if: CALL 'public final fun EQEQ (arg0: kotlin.Any?, arg1: kotlin.Any?): kotlin.Boolean declared in kotlin.internal.ir' type=kotlin.Boolean origin=EQEQ
arg0: GET_VAR 'var ch: kotlin.Char? [var] declared in <root>.consumeRestOfQuotedSequence' type=kotlin.Char? origin=null
arg1: CALL 'private final fun <get-BACKSLASH> (): kotlin.Char declared in <root>' type=kotlin.Char origin=GET_PROPERTY
arg1: CONST Char type=kotlin.Char value='\\'
then: BLOCK type=@[FlexibleNullability] java.lang.StringBuilder? origin=SAFE_CALL
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Char? [val]
CALL 'private final fun nextChar (): kotlin.Char? declared in <root>' type=kotlin.Char? origin=null
@@ -22,7 +22,7 @@ fun Reader.consumeRestOfQuotedSequence(sb: StringBuilder, quote: Char) {
else -> false
}) { // BLOCK
when {
EQEQ(arg0 = ch, arg1 = <get-BACKSLASH>()) -> { // BLOCK
EQEQ(arg0 = ch, arg1 = '\\') -> { // BLOCK
val tmp1_safe_receiver: Char? = <this>.nextChar()
when {
EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null