[IR] Specify IrType in irTemporary

This commit is contained in:
Svyatoslav Kuzmich
2018-10-31 15:48:51 +03:00
parent dd20775662
commit 81d61aefff
2 changed files with 7 additions and 4 deletions
@@ -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
)
}