Should generic `@Composable` `fun`s work with Comp...
# compose-web
n
Should generic
@Composable
`fun`s work with Compose/Web? I get internal compiler error in case of this function:
Copy code
@Composable
fun <T> MySelect(
    options: List<T>,
    onChange: (T?) -> Unit
) ...
If I remove the generic type parameter (and replace
T
with
Any
in the parameters) then it compiles. Kotlin: 1.5.31 Compose/Web: 1.0.0-alpha4-build366 Error message:
Copy code
java.lang.IllegalStateException: FULL: FUN name:MySelect$composable visibility:public modality:FINAL <T> (options:kotlin.collections.List<T of ...component.MySelect$composable>, onChange:kotlin.Function1<T of ...component.MySelect$composable?, kotlin.Unit>, $composer:androidx.compose.runtime.Composer?, $changed:<http://kotlin.Int|kotlin.Int>) returnType:kotlin.Unit
 Ir: ...component#MySelect$composable(kotlin.collections.List<0:0>;kotlin.Function1<0:0?,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int){0�<kotlin.Any?>}
 Descriptor: ...component#MySelect$composable(kotlin.collections.List<0:0>;kotlin.Function1<0:0,kotlin.Unit>;androidx.compose.runtime.Composer?;kotlin.Int){0�<kotlin.Any?>}
o
It’s serialization + Compose plugins. Could you separate modules do that each plugin is used in its own module?
n
The serialization plugin is not applied on the Compose/Web project:
Copy code
plugins {
    kotlin("multiplatform")
    id("org.jetbrains.compose") version "1.0.0-alpha4-build366"
}
But I have a plugin block in the root project:
Copy code
plugins {
    kotlin("multiplatform") version "1.5.31" apply false
    kotlin("plugin.serialization") version "1.5.31" apply false
...
Is it disallowed as well to have an unapplied serialization plugin?
@olonho, I have removed the unapplied serialization plugin from the root project but the problem still exists :(
o
backtrace includes application of serialization compiler plugin, so if it is removed - backtrace shall be different
n
@olonho, I removed every shared plugin from the root project (except for
kotlin("multiplatform")
) but it still fails with the same error message. Isn't it suspicious that it works if I remove the type parameter? These are the
project.plugins
(printed from
afterEvaluate
of the Compose/Web project): • com.android.ide.gradle.model.builder.AndroidStudioToolingPlugin • org.gradle.api.plugins.HelpTasksPlugin • org.gradle.buildinit.plugins.BuildInitPlugin • org.gradle.buildinit.plugins.WrapperPlugin • org.jetbrains.compose.ComposeCompilerKotlinSupportPlugin • org.jetbrains.compose.ComposePlugin • org.gradle.language.base.plugins.LifecycleBasePlugin • org.gradle.api.plugins.BasePlugin • org.gradle.api.plugins.JvmEcosystemPlugin • org.gradle.api.plugins.ReportingBasePlugin • org.gradle.api.plugins.JavaBasePlugin$Inject • org.jetbrains.kotlin.gradle.scripting.internal.ScriptingKotlinGradleSubplugin • org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin • org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper • org.gradle.kotlin.dsl.provider.plugins.KotlinScriptBasePlugin • org.jetbrains.kotlin.gradle.targets.js.npm.NpmResolverPlugin As you see, the
org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin
is not applied (it is applied only in a project that is a dependency of the Compose/Web project).
Meanwhile, the issue has been kind of "solved" 😞 https://github.com/JetBrains/compose-jb/issues/1226#issuecomment-933292157