jw
09/07/2022, 5:27 PMjw
09/07/2022, 5:30 PMKParameterImpl
has the KFunctionImpl
in its private callable
property, but I can't get access to that as far as I can telljw
09/07/2022, 5:31 PMephemient
09/07/2022, 5:32 PM(T) -> R
and T.() -> R
are represented by the same kotlin.Function1<T, R>
which is erased to kotlin.jvm.internal.Function1
on JVM: https://github.com/JetBrains/kotlin/blob/master/spec-docs/function-types.mdjw
09/07/2022, 5:33 PMephemient
09/07/2022, 5:35 PMjw
09/07/2022, 5:36 PMjw
09/07/2022, 5:36 PMephemient
09/07/2022, 5:40 PMkotlin.reflect.typeOf<Unit.() -> Unit>() == kotlin.reflect.typeOf<(Unit) -> Unit>()
I don't think kotlin-reflect exposes any difference :-/jw
09/07/2022, 8:16 PMtype.annotations.any { it.annotationClass == ExtensionFunctionType::class }
ephemient
09/07/2022, 8:27 PM>>> fun f(block: (Unit) -> Unit) = Unit
>>> fun g(block: Unit.() -> Unit) = Unit
>>> ::f.parameters.single().type.annotations
res0: List<Annotation> = []
>>> ::g.parameters.single().type.annotations
res1: List<Annotation> = [@kotlin.ExtensionFunctionType()]
>>> ::f.parameters.single().type == ::g.parameters.single().type
res2: Boolean = true
>>> typeOf<Unit.() -> Unit>().annotations
res3: List<Annotation> = []
… ok, I guess that works, but it's kinda surprisingjw
09/07/2022, 8:27 PMephemient
09/07/2022, 8:40 PM@kotlin.ContextFunctionTypeParams(count: Int)
and @kotlin.ParameterName(name: String)
(the latter on the type parameters to FunctionN<>
), and the lambda type also seems to know if it's a suspend
function, but I'm not sure how that's determinedephemient
09/07/2022, 8:40 PM