https://kotlinlang.org logo
g

Godwin Joseph

03/21/2022, 5:09 PM
While developing a custom plugin for kotlin, I have found a problem that, I can't get the typeReference when writing Single-expression functions. The code block is given below.
Copy code
val element: KtNamedFunction =//from another FUN
if(element.typeReference!= null){
   if (it.text != "Unit") {
        print(return type)
   }
}
Sample function 1
Copy code
fun abc():Int{
    return 0
}
Sample function 2
Copy code
fun abcd()=0
When executing the first function I am getting
Int
as the typeReference. But when executing the second, I am getting
null
as typeReference. Why I am getting
null
when using Single-expression functions? How to solve it?