[IR] Specify IrType in irTemporary
This commit is contained in:
@@ -50,9 +50,10 @@ inline fun IrBuilderWithScope.irLetS(
|
||||
fun <T : IrElement> IrStatementsBuilder<T>.irTemporary(
|
||||
value: IrExpression,
|
||||
nameHint: String? = null,
|
||||
typeHint: KotlinType? = null
|
||||
typeHint: KotlinType? = null,
|
||||
irType: IrType? = null
|
||||
): IrVariable {
|
||||
val temporary = scope.createTemporaryVariable(value, nameHint, type = typeHint)
|
||||
val temporary = scope.createTemporaryVariable(value, nameHint, type = typeHint, irType = irType)
|
||||
+temporary
|
||||
return temporary
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.ir.symbols.IrSymbol
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.IrFieldSymbolImpl
|
||||
import org.jetbrains.kotlin.ir.symbols.impl.createFunctionSymbol
|
||||
import org.jetbrains.kotlin.ir.types.IrType
|
||||
import org.jetbrains.kotlin.ir.types.impl.originalKotlinType
|
||||
import org.jetbrains.kotlin.ir.types.toKotlinType
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
@@ -61,7 +62,8 @@ class Scope(val scopeOwnerSymbol: IrSymbol) {
|
||||
nameHint: String? = null,
|
||||
isMutable: Boolean = false,
|
||||
type: KotlinType? = null,
|
||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE
|
||||
origin: IrDeclarationOrigin = IrDeclarationOrigin.IR_TEMPORARY_VARIABLE,
|
||||
irType: IrType? = null
|
||||
): IrVariable {
|
||||
val originalKotlinType = type ?: (irExpression.type.originalKotlinType ?: irExpression.type.toKotlinType())
|
||||
return IrVariableImpl(
|
||||
@@ -70,7 +72,7 @@ class Scope(val scopeOwnerSymbol: IrSymbol) {
|
||||
originalKotlinType,
|
||||
nameHint, isMutable
|
||||
),
|
||||
irExpression.type,
|
||||
irType ?: irExpression.type,
|
||||
irExpression
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user