Hello, I want to change the type of the annotated ...
# compiler
a
Hello, I want to change the type of the annotated function, and then I discovered a difficulty. After I changed it, all types associated with it must be modified.
Copy code
fun function(){
  val lambda=@Annotaed {}
  val lambdaList=listOf(lambda)
}
Assuming that
@Annotated
will change the type
()->Unit
to
(Node)->Unit
, then the type of the variable
lambda
,
lambdaList
, and the generic parameter type of
listOf
all need to be modified. However, it is obviously not a good idea to manually traverse and modify all the places where it may be used when an annotated function is found. Any idea if there is some mechanism or utils to achieve this? I know compose does this job very well, although I don't understand how.
i
I think you still need to manually traverse these different IRs to modify them, just like in compose https://android.googlesource.com/platform/frameworks/support/+/7a7fa5271d841bcebe637e0dc8[…]/compiler/plugins/kotlin/lower/ComposableTypeRemapper.kt
a
Got it, thank you!