FIR2IR: make IrGetValue type consistent with IrVariable type
#KT-55458 Fixed
This commit is contained in:
committed by
Space Team
parent
1c4d9175e7
commit
f0ea8ab81b
@@ -1210,6 +1210,9 @@ class Fir2IrDeclarationStorage(
|
||||
irParent: IrDeclarationParent,
|
||||
givenOrigin: IrDeclarationOrigin? = null
|
||||
): IrVariable = convertCatching(variable) {
|
||||
// Note: for components call, we have to change type here (to original component type) to keep compatibility with PSI2IR
|
||||
// Some backend optimizations related to withIndex() probably depend on this type: index should always be Int
|
||||
// See e.g. forInStringWithIndexWithExplicitlyTypedIndexVariable.kt from codegen box tests
|
||||
val type = ((variable.initializer as? FirComponentCall)?.typeRef ?: variable.returnTypeRef).toIrType()
|
||||
// Some temporary variables are produced in RawFirBuilder, but we consistently use special names for them.
|
||||
val origin = when {
|
||||
|
||||
+4
-1
@@ -458,7 +458,10 @@ class CallAndReferenceGenerator(
|
||||
|
||||
is IrValueSymbol -> {
|
||||
IrGetValueImpl(
|
||||
startOffset, endOffset, type, symbol,
|
||||
// Note: sometimes we change an IR type of local variable
|
||||
// (see component call case: Fir2IrDeclarationStorage.createIrVariable -> val type = ...)
|
||||
// That's why we should use here v the IR variable type and not FIR converted type (to prevent IR inconsistency)
|
||||
startOffset, endOffset, symbol.owner.type, symbol,
|
||||
origin = if (variableAsFunctionMode) IrStatementOrigin.VARIABLE_AS_FUNCTION
|
||||
else calleeReference.statementOrigin()
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user