'Not found typeReference on KtNamedFunction when using Single-expression functions - Kotlin

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.

val element: KtNamedFunction =//from another FUN
if(element.typeReference!= null){
   if (it.text != "Unit") {
        print(return type)
   }
} 

Sample function 1

fun abc():Int{
    return 0
}

Sample function 2

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?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source