IrConstTransformer: transform constants also inside call children
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ class IrConstTransformer(private val interpreter: IrInterpreter, private val irF
|
|||||||
if (expression.accept(IrCompileTimeChecker(mode = EvaluationMode.ONLY_BUILTINS), null)) {
|
if (expression.accept(IrCompileTimeChecker(mode = EvaluationMode.ONLY_BUILTINS), null)) {
|
||||||
return interpreter.interpret(expression, irFile).replaceIfError(expression)
|
return interpreter.interpret(expression, irFile).replaceIfError(expression)
|
||||||
}
|
}
|
||||||
return expression
|
return super.visitCall(expression)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitField(declaration: IrField): IrStatement {
|
override fun visitField(declaration: IrField): IrStatement {
|
||||||
|
|||||||
@@ -55,5 +55,10 @@ fun box(): String {
|
|||||||
Some()
|
Some()
|
||||||
Other()
|
Other()
|
||||||
Another()
|
Another()
|
||||||
|
run {
|
||||||
|
@State(name = "A", storages = [(Storage(value = StoragePathMacros.NON_ROAMABLE_FILE))])
|
||||||
|
class Local
|
||||||
|
Local()
|
||||||
|
}
|
||||||
return "OK"
|
return "OK"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// !LANGUAGE: -InlineConstVals
|
// !LANGUAGE: -InlineConstVals
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// FIR status: don't support legacy feature
|
||||||
|
|
||||||
const val z = 0
|
const val z = 0
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
// !LANGUAGE: -InlineConstVals
|
// !LANGUAGE: -InlineConstVals
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// FIR status: don't support legacy feature
|
||||||
|
|
||||||
const val one = 1
|
const val one = 1
|
||||||
const val two = 2
|
const val two = 2
|
||||||
|
|||||||
+2
@@ -1,4 +1,6 @@
|
|||||||
// !LANGUAGE: -InlineConstVals
|
// !LANGUAGE: -InlineConstVals
|
||||||
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
|
// FIR status: don't support legacy feature
|
||||||
|
|
||||||
const val y = "cde"
|
const val y = "cde"
|
||||||
|
|
||||||
|
|||||||
@@ -398,8 +398,7 @@ FILE fqName:<root> fileName:/ArrayMap.kt
|
|||||||
<T>: T of <root>.ArrayMapImpl
|
<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
|
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
|
<T>: kotlin.Any
|
||||||
size: CALL 'private final fun <get-DEFAULT_SIZE> (): kotlin.Int declared in <root>.ArrayMapImpl.Companion' type=kotlin.Int origin=GET_PROPERTY
|
size: CONST Int type=kotlin.Int value=20
|
||||||
$this: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=<root>.ArrayMapImpl.Companion
|
|
||||||
PROPERTY name:size visibility:public modality:FINAL [var]
|
PROPERTY name:size visibility:public modality:FINAL [var]
|
||||||
overridden:
|
overridden:
|
||||||
public abstract size: kotlin.Int [val]
|
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 '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: 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
|
$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
|
other: CONST Int type=kotlin.Int value=2
|
||||||
$this: GET_OBJECT 'CLASS OBJECT name:Companion modality:FINAL visibility:public [companion] superTypes:[kotlin.Any]' type=<root>.ArrayMapImpl.Companion
|
|
||||||
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]
|
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:
|
overridden:
|
||||||
public abstract fun set (index: kotlin.Int, value: T of <root>.ArrayMap): kotlin.Unit [operator] declared in <root>.ArrayMap
|
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() {
|
constructor() {
|
||||||
this/*ArrayMapImpl*/<T>(data = arrayOfNulls<Any>(size = Companion.<get-DEFAULT_SIZE>()))
|
this/*ArrayMapImpl*/<T>(data = arrayOfNulls<Any>(size = 20))
|
||||||
}
|
}
|
||||||
|
|
||||||
override var size: Int
|
override var size: Int
|
||||||
@@ -183,7 +183,7 @@ internal class ArrayMapImpl<T : Any> : ArrayMap<T> {
|
|||||||
private fun ensureCapacity(index: Int) {
|
private fun ensureCapacity(index: Int) {
|
||||||
when {
|
when {
|
||||||
lessOrEqual(arg0 = <this>.<get-data>().<get-size>(), arg1 = index) -> { // BLOCK
|
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)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ FILE fqName:<root> fileName:/coercionToUnitForNestedWhen.kt
|
|||||||
BRANCH
|
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
|
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
|
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
|
then: BLOCK type=@[FlexibleNullability] java.lang.StringBuilder? origin=SAFE_CALL
|
||||||
VAR IR_TEMPORARY_VARIABLE name:tmp_1 type:kotlin.Char? [val]
|
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
|
CALL 'private final fun nextChar (): kotlin.Char? declared in <root>' type=kotlin.Char? origin=null
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ fun Reader.consumeRestOfQuotedSequence(sb: StringBuilder, quote: Char) {
|
|||||||
else -> false
|
else -> false
|
||||||
}) { // BLOCK
|
}) { // BLOCK
|
||||||
when {
|
when {
|
||||||
EQEQ(arg0 = ch, arg1 = <get-BACKSLASH>()) -> { // BLOCK
|
EQEQ(arg0 = ch, arg1 = '\\') -> { // BLOCK
|
||||||
val tmp1_safe_receiver: Char? = <this>.nextChar()
|
val tmp1_safe_receiver: Char? = <this>.nextChar()
|
||||||
when {
|
when {
|
||||||
EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null
|
EQEQ(arg0 = tmp1_safe_receiver, arg1 = null) -> null
|
||||||
|
|||||||
Reference in New Issue
Block a user