[Native] Always cast expression to the expected type after inline
Right now, during the process of inlining, the compiler erases types. Because of that, we can end up with some random type (for example, `Any`) where the concrete type was expected (for example, `Int`). Compiler must insert a cast in the required places. #KT-66017 Fixed
This commit is contained in:
+2
-1
@@ -347,7 +347,8 @@ private val inlinePhase = createFileLoweringPhase(
|
||||
FunctionInlining(
|
||||
context.context,
|
||||
NativeInlineFunctionResolver(context.context, context),
|
||||
alwaysCreateTemporaryVariablesForArguments = context.shouldContainDebugInfo()
|
||||
alwaysCreateTemporaryVariablesForArguments = true,
|
||||
insertAdditionalImplicitCasts = true,
|
||||
).lower(irFile)
|
||||
}
|
||||
}
|
||||
|
||||
+1
@@ -214,6 +214,7 @@ internal class VolatileFieldsLowering(val context: Context) : FileLoweringPass {
|
||||
expectedReturn == null && expression is IrReturnableBlock -> getConstPropertyReference(expression.singleExpressionOrNull, expression.symbol)
|
||||
expression is IrReturn && expression.returnTargetSymbol == expectedReturn -> getConstPropertyReference(expression.value, null)
|
||||
expression is IrBlock -> getConstPropertyReference(expression.singleExpressionOrNull, expectedReturn)
|
||||
expression is IrTypeOperatorCall && expression.operator == IrTypeOperator.IMPLICIT_CAST -> getConstPropertyReference(expression.argument, expectedReturn)
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user