I can have
val composeFunction = remember { mutableStateOf ({}) }
I can have
val composeFF = @Composable { Text("ABC") }
val composeFunction = remember { mutableStateOf (composeFF) }
Why can't I have
val composeFunction = remember { mutableStateOf (@Composable { Text("ABC") }) }
It errors out state
Internal Error occurred while analyzing this expression
(Please use the "
" icon in the bottom-right corner to report this error):
jar:file:/Applications/Android%20Studio.app/Contents/lib/platform-impl.jar!/general/error.svg
Type inference failed. Expected type mismatch: inferred type is @Composable () -> Unit but () -> Unit was expected
Have you tried specifying the type?
Looks like the compiler cannot infer an ordinary function to something that is supplied with a
@ComposableannotationUpdate:
It turns out
@Composableannotation actually modifies the function type, similar to what suspend modifier does.Based on this arcticle,
furthermore,