1

I'm using KotlinPoet for annotation processing, but I've got an issue. I need return function in generated class, but I'm not sure that KotlinPoet can do it? If you have some experience, please help me.

That I can do:

fun test(): String = ...

That I need to do

fun test(): () -> String = ...
Vanya Sakharovskiy
  • 295
  • 1
  • 3
  • 16

1 Answers1

6

Similar to ClassName or TypeName, you can use LambdaTypeName to create a function type with no parameters and String return type:

val type = LambdaTypeName.get(returnType = String::class.asTypeName())
Egor
  • 39,695
  • 10
  • 113
  • 130