[PL] Fix: Respect inlined array constructor lambdas

This commit is contained in:
Dmitriy Dolovov
2023-03-23 17:11:34 +01:00
committed by Space Team
parent 5baeae3bfd
commit 66532d714e
4 changed files with 33 additions and 3 deletions
@@ -895,11 +895,12 @@ internal class PartiallyLinkedIrTreePatcher(
}
) { super.visitBlockBody(body) }
override fun visitCall(expression: IrCall) = withContext(
// Allows visiting any type of call: IrCall, IrConstructorCall, IrEnumConstructorCall, IrDelegatingConstructorCall.
override fun visitFunctionAccess(expression: IrFunctionAccessExpression) = withContext(
{ oldContext ->
val functionSymbol = expression.symbol
val function = if (functionSymbol.isBound) functionSymbol.owner else return@withContext oldContext
if (!function.isInline) return@withContext oldContext
if (!function.isInline && !function.isInlineArrayConstructor(builtIns)) return@withContext oldContext
fun IrValueParameter?.canHaveNonLocalReturns(): Boolean = this != null && !isCrossinline && !isNoinline
@@ -925,7 +926,7 @@ internal class PartiallyLinkedIrTreePatcher(
inlinedLambdaArgumentsWithPermittedNonLocalReturns = inlinedLambdaArgumentsWithPermittedNonLocalReturns.toSet()
)
}
) { super.visitCall(expression) }
) { super.visitFunctionAccess(expression) }
override fun visitReturn(expression: IrReturn) = withContext { context ->
expression.maybeThrowLinkageError(transformer = this@NonLocalReturnsPatcher) {