Skip to content

Commit

Permalink
fix jvm-only symbols rememberComposableLambdaNFunction and composable…
Browse files Browse the repository at this point in the history
…LambdaNFunction being accessed for non-jvm targets
  • Loading branch information
eymar committed Feb 14, 2024
1 parent 1c9bd81 commit bccd756
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.platform.isJs
import org.jetbrains.kotlin.platform.isWasm
import org.jetbrains.kotlin.platform.jvm.isJvm
import org.jetbrains.kotlin.platform.konan.isNative

private class CaptureCollector {
val captures = mutableSetOf<IrValueDeclaration>()
Expand Down Expand Up @@ -869,24 +870,23 @@ class ComposerLambdaMemoization(
val function = expression.function
val argumentCount = function.valueParameters.size

val isJsOrWasm = context.platform.isJs() || context.platform.isWasm()
if (argumentCount > MAX_RESTART_ARGUMENT_COUNT && isJsOrWasm) {
val isJsOrWasmOrNative = context.platform.isJs() || context.platform.isWasm() || context.platform.isNative()
if (argumentCount > MAX_RESTART_ARGUMENT_COUNT && isJsOrWasmOrNative) {
error(
"only $MAX_RESTART_ARGUMENT_COUNT parameters " +
"in @Composable lambda are supported on K/JS or K/Wasm"
"in @Composable lambda are supported on K/JS or K/Wasm or K/Native"
)
}

val useComposableLambdaN = argumentCount > MAX_RESTART_ARGUMENT_COUNT
val useComposableFactory = collector.hasCaptures && declarationContext.composable
val rememberComposableN = rememberComposableLambdaNFunction ?: composableLambdaNFunction
val rememberComposable = rememberComposableLambdaFunction ?: composableLambdaFunction
val requiresExplicitComposerParameter = useComposableFactory &&
rememberComposableLambdaFunction == null
val restartFactorySymbol =
if (useComposableFactory)
if (useComposableLambdaN)
rememberComposableN
rememberComposableLambdaNFunction ?: composableLambdaNFunction
else rememberComposable
else if (useComposableLambdaN)
composableLambdaInstanceNFunction
Expand Down

0 comments on commit bccd756

Please sign in to comment.