I’ve upgraded to <#C01D6HTPATV|compose-desktop> 0.4.0-build183 and started getting this error: ```e:...
o
I’ve upgraded to #compose-desktop 0.4.0-build183 and started getting this error:
Copy code
e: …/SnakeLayout.kt: (30, 42): Type inference failed. Expected type mismatch: inferred type is @Composable() (Int, T) -> Unit but (Int, T) -> Unit was expected
Code is kinda like this:
Copy code
fun <T> SnakeLayout(…,
    content: @Composable (Int, T) -> Unit) {
    Layout(…,
        content = { items.forEachIndexed(content) } // here
    ) { … }
}
If I expand the call to
items.forEachIndexed { i, t -> content(i,t) }
it works fine. In version 0.4.0-build180 both variants worked. (posting here, because I believe it is more to do with compiler plugin than desktop lib)
d
Somewhere on this channel is a ticket about the compose compiler plugin recently not handling inline functions properly. It's probably the same as this.
a
Yeah I'd wager that it's the same issue.
@Composable
functions have extra hidden parameters so passing
content
to
forEachIndexed
isn't having the expected results. Use the lambda call syntax instead with braces and explicitly passing the parameters to
content
and you should be back up and running.
Please feel free to file an issue on the tracker and we'll deduplicate it as needed.