https://kotlinlang.org logo
#kapt
Title
# kapt
r

raulraja

11/03/2018, 1:40 AM
Is there a way in kapt to get a hold of the structure of a function literal with receiver? When I try to extract info from
TypeElement
or the Kotlin Metadata library by @Eugenio for a function of the shape:
A.() -> B
it always shows up as
Function1<A, B>
but I have not found a place or API that denotes the declaration of such function as being the type of a receiver function.
e

Eugenio

11/03/2018, 2:30 PM
I think there's something like
Protobuf.Function.receiverType
if I remember correctly 🤔
r

raulraja

11/04/2018, 1:11 PM
The issue is that the type does not represent a Function but the type of an argument of a function, so the only thing I have access there to is the
me.eugeniomarletti.kotlin.metadata.shadow.metadata.ProtoBuf.Function#getValueParameterList
which gives me a
me.eugeniomarletti.kotlin.metadata.shadow.metadata.ProtoBuf.ValueParameter#getType
when I query that
type
I see no useful info to determine the type is referring to a literal receiver function of the shape
A.() -> B
e

Eugenio

11/04/2018, 1:28 PM
oh, right, try searching for the
kotlin.ExtensionFunctionType
annotation in `Protobuf.Type.jvmTypeAnnotation`: it's a marker annotation that denotes function types with a receiver 😉
r

raulraja

11/04/2018, 2:29 PM
Awesome, thanks!