How to get return type (IrType) of lambda represen...
# compiler
p
How to get return type (IrType) of lambda represented as IrType?
Copy code
// suppose there is function
fun test(lambda: (Type1,Type2, ...) -> ReturnType) {...}
// in IR compiler plugin there is code
val testFun: IrFunction = <get test function>
val lambdaArg: IrType = testFun.valueParameters[0]
// lambdaArg is type of lambda. How to get return type of lambdaArg?
j
It should be the last type argument
👍 1
thank you color 1
Sorry I don't seem to do this in IR anywhere. Only FIR. So don't have a snippet that I can quickly find.
p
Thanks! Last type argument is returning right type
w
(lambdaArg as IrSimpleType).arguments.last()
thank you color 1