https://kotlinlang.org logo
#multiplatform
Title
# multiplatform
j

Jan

11/03/2023, 9:44 PM
Any idea why my MP project targetting JS and Android fails to compile on JS with
e: kotlin.NotImplementedError: Generation of stubs for class org.jetbrains.kotlin.ir.symbols.impl.IrValueParameterSymbolImpl is not supported yet
but on Android it works completely fine. Newest Compose, Kotlin, Gradle and AGP version. Link: https://github.com/jan-tennert/EinkaufszettelMP
p

Pablichjenkov

11/03/2023, 9:54 PM
You can ask in #compose-web
j

Jan

11/03/2023, 9:56 PM
I mean it isn't necessarily a compose issue, it compiled before this commit (and it already included compose)
p

Pablichjenkov

11/03/2023, 9:56 PM
Let me see
Try commenting out one dependency at a time.
Is either koin or voyager
I think somebody was having some issues with voyager and kotlin 1.9.20
j

Jan

11/03/2023, 10:00 PM
Okay its koin-compose 🤔
I'll create an issue
p

Pablichjenkov

11/03/2023, 10:03 PM
I see you added a specific koin artifact for Android, don't you miss the counter side in JS?
j

Jan

11/03/2023, 10:05 PM
The koin-android dependency just includes things to add the android context etc. nothing you need on other targets
p

Pablichjenkov

11/03/2023, 10:05 PM
I see you are correct
JS is just commonMain
j

Jan

11/03/2023, 10:24 PM
okay nvm can't repoduce it in another project. Also just commenting the content of the method
Content
in this file: https://github.com/jan-tennert/EinkaufszettelNext/blob/master/composeApp/src/commo[…]otlin/io/github/jan/einkaufszettel/ui/screen/auth/AuthScreen.kt Also fixes the compilation error
(the dependency is still there)
p

Pablichjenkov

11/03/2023, 10:33 PM
Interesting, cmd + click to see what's inside
Is that a Composable extension function on ?
j

Jan

11/03/2023, 10:35 PM
It's my own dependency, it's this and/or the implementation (for JS)
p

Pablichjenkov

11/03/2023, 10:36 PM
Yeah is a Composable extension function, I believe JS compiler was still struggling with this.
If I am not mistaken there are some open issues for these
Try changing your design.
Remove the Composable in the extension function and just call a regular Composable function that internally call the extension function
j

Jan

11/03/2023, 10:40 PM
I'm confused, so the
ComposeAuth.rememberLoginWithGoogle
shouldn't be an extension function?
p

Pablichjenkov

11/03/2023, 10:42 PM
The Composable annotation on it
Try without it.
j

Jan

11/03/2023, 10:43 PM
yea but the implementation does need to be in a composable, or doesn't that matter?
the implementation (in this case JS) calls
defaultLoginBehavior
which itself uses a LaunchedEffect
p

Pablichjenkov

11/03/2023, 10:47 PM
Try like this see if it works
Copy code
actual fun ComposeAuth.rememberLoginWithGoogle(onResult: (NativeSignInResult) -> Unit, fallback: suspend () -> Unit): NativeSignInState = defaultLoginBehavior(fallback)

@Composable 
actual rememberLoginWithGoogleWrap(onResult: (NativeSignInResult) -> Unit, fallback: suspend () -> Unit) {
    rememberLoginWithGoogle(fallback)
}

// commonMain
@Composable 
expect rememberLoginWithGoogleWrap(onResult: (NativeSignInResult) -> Unit, fallback: suspend () -> Unit)
j

Jan

11/03/2023, 10:49 PM
so I just remove the composable annotation on
rememberLoginWithGoogle
?
p

Pablichjenkov

11/03/2023, 10:49 PM
Yes
j

Jan

11/03/2023, 10:50 PM
also on the common
rememberLoginWithGoogle
or just the JS actual one?
p

Pablichjenkov

11/03/2023, 10:51 PM
You have to do it in commonMain or the compiler will complain
j

Jan

11/03/2023, 10:51 PM
okay so both
👌 1
Okay publishing it to maven local rn, but shouldn't it generally complain because rememberLoginWithGoogle (which is not a composable) calls a composable function?
p

Pablichjenkov

11/03/2023, 10:56 PM
Yes that is right, let me read the code again
I think you will have to call
defaultLoginBehavior
directly
j

Jan

11/03/2023, 11:03 PM
hmm that is definitly inconvenient
p

Pablichjenkov

11/03/2023, 11:03 PM
It is yes
Not sure if making it inline could help, But still you can call inline from Composab;e but not the other way
j

Jan

11/03/2023, 11:04 PM
yea thought about that too but that doesn't sound like the right solution
I'll try that and see if it helps
p

Pablichjenkov

11/03/2023, 11:05 PM
I know, It is hard to mix the JS target with other target because this type of things.
You can’t use all the kotlin goodies
j

Jan

11/03/2023, 11:12 PM
probably will do a workaround for my project for now, I don't know how I could fix that in the dependency so that it doesn't break other things
p

Pablichjenkov

11/03/2023, 11:25 PM
I actually checked and I have similar code in some of my projects and it compiles. Uses an extension lambda
Can you check the library you are using, what kotlin version it was compiled with. I am thinking of some binary incompatibility or something
Copy code
val TopBarComponentView: @Composable TopBarComponent<TopBarComponentViewModel>.(
        modifier: Modifier,
        activeChildComponent: Component
    ) -> Unit = { modifier, activeChildComponent -> ... }
That works for me an is basically a lambda extension function. Maybe a lambda works for you The only thing I don't see is the expect/actual symbol. Hopefully has nothing to do with it
j

Jan

11/04/2023, 12:29 PM
Hey, so both the library and my app use Kotlin 1.9.20 and Compose 1.5.10, and for your solution: I can try that but that would obviously be a breaking change
p

Pablichjenkov

11/04/2023, 7:50 PM
Ah I see 👍
5 Views