Hey guys! Any Idea on how to disambiguate an exten...
# compose
r
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
They look identical
Also keep everything to one thread and not multiple posts
r
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
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
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
If it compiles and runs, then it’s a studio bug
r
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
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
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
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
I'll report it. Thanks!
a