[IR] Extracted implicitCastIfNeeded to common utils
This commit is contained in:
-7
@@ -407,13 +407,6 @@ class FunctionInlining(
|
||||
override fun visitElement(element: IrElement) = element.accept(this, null)
|
||||
}
|
||||
|
||||
private fun IrExpression.implicitCastIfNeededTo(type: IrType) =
|
||||
// No need to cast expressions of type nothing
|
||||
if (type == this.type || (insertAdditionalImplicitCasts && this.type == context.irBuiltIns.nothingType))
|
||||
this
|
||||
else
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.IMPLICIT_CAST, type, this)
|
||||
|
||||
// With `insertAdditionalImplicitCasts` flag we sometimes insert
|
||||
// casts to inline lambda parameters before calling `invoke` on them.
|
||||
// Unwrapping these casts helps us satisfy inline lambda call detection logic.
|
||||
|
||||
@@ -183,6 +183,12 @@ fun IrExpression.coerceToUnitIfNeeded(valueType: IrType, irBuiltIns: IrBuiltIns,
|
||||
)
|
||||
}
|
||||
|
||||
fun IrExpression.implicitCastIfNeededTo(type: IrType) =
|
||||
if (type == this.type || this.type.isNothing())
|
||||
this
|
||||
else
|
||||
IrTypeOperatorCallImpl(startOffset, endOffset, type, IrTypeOperator.IMPLICIT_CAST, type, this)
|
||||
|
||||
fun IrFunctionAccessExpression.usesDefaultArguments(): Boolean =
|
||||
symbol.owner.valueParameters.any { this.getValueArgument(it.index) == null }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user