https://kotlinlang.org logo
#compose
Title
# compose
r

Raymond

12/06/2023, 7:28 PM
Hey guys! Any Idea on how to disambiguate an extension function that is named the same as a regular function? They're both in the same package and have the same signature (except for the receiver). The "usual" hack of storing its reference in a variable typed with the signature of the target function does not work, as composable function references are not currently supported. It's being a real pain (edited)
k

Kirill Grouchnikov

12/06/2023, 7:43 PM
They look identical
Also keep everything to one thread and not multiple posts
r

Raymond

12/06/2023, 7:46 PM
Updated. The second one is an extension function. The first one is a regular function. I'm trying to use the first one
Do you know a way to attach a snippet together with a message?
k

Kirill Grouchnikov

12/06/2023, 7:53 PM
The implementation of these functions is the same, so it shouldn’t matter which one you’re “getting” in this particular instance
In terms of the server etiquette, you post the short description in the main post, and then a comment with the full snippet - that way the main stream is kept clean and not commandeered by huge code chunks
🙌 1
r

Raymond

12/06/2023, 7:56 PM
Screenshot 2023-12-06 at 4.55.50 PM.png,Screenshot 2023-12-06 at 4.56.08 PM.png
Would it be an android studio bug?
It tries to use the ColumnScope.AnimatedVisibility() extension instead of the regular one
k

Kirill Grouchnikov

12/06/2023, 8:01 PM
If it compiles and runs, then it’s a studio bug
r

Raymond

12/06/2023, 8:02 PM
Nope, it does not compiles. this is the exception: e: file///.../CoinDetails.kt705:17 'fun ColumnScope.AnimatedVisibility(visible: Boolean, modifier: Modifier = ..., enter: EnterTransition = ..., exit: ExitTransition = ..., label: String = ..., content: AnimatedVisibilityScope.() -> Unit): Unit' can't be called in this context by implicit receiver. Use the explicit one if necessary
As the function I'm trying to use does not have a receiver, I don't know what to do
k

Kirill Grouchnikov

12/06/2023, 8:12 PM
At this point, it’s time to make the smallest self-contained sample you can that shows this issue. Ideally just one composable function that can be copy-pasted as is into a new project in studio. That way people can take a look in their environment.
r

Raymond

12/06/2023, 8:17 PM
Here is the minimum faulty code
It happens when the composable is indirectly inside a column
If you remove the outer column, it works fine
s

shikasd

12/06/2023, 10:50 PM
It's a Kotlin bug, it tries to resolve the extension one, probably worth reporting As a workaround, you can just create your own AnimatedVisibility wrapper that calls the one you need with a different name and call it here.
r

Raymond

12/06/2023, 10:52 PM
I'll report it. Thanks!
a

Albert Chang

12/07/2023, 1:36 AM
2 Views