KaFunctionTypeFamily¶
@SubclassOptInRequired(markerClass = [KaImplementationDetail::class])
interface KaFunctionTypeFamily
Describes a family of numbered function types such as Function0, Function1, ..., FunctionN.
Kotlin has the following built-in function type families:
-
Function— regular function types, e.g.,(Int) -> String -
SuspendFunction— suspend function types, e.g.,suspend () -> Unit -
KFunction— reflection types for regular functions -
KSuspendFunction— reflection types for suspend functions
Compiler plugins may introduce additional custom function type families.
See also¶
Inheritors¶
Properties¶
isInlinable¶
abstract val isInlinable: Boolean
Whether function types in this family can be inlined by the compiler.
For built-in families, Function and SuspendFunction are inlinable, while KFunction and KSuspendFunction are not.
isReflect¶
Whether this family represents reflection function types (KFunction, KSuspendFunction).
isSuspend¶
Whether this family represents suspend function types (SuspendFunction, KSuspendFunction).
markerAnnotationClassId¶
abstract val markerAnnotationClassId: ClassId?
The ClassId of the annotation which marks a function type as belonging to this family, such as androidx.compose.runtime.Composable.
Families provided by a compiler plugin always have such an annotation, while built-in families have none.
maxArity¶
The maximum number of parameters supported by function types in this family.
nameBase¶
The class name prefix shared by all types in this family.
For example, "Function" for the Function family, "SuspendFunction" for the SuspendFunction family.
supportsConversionFromSimpleFunctionType¶
abstract val supportsConversionFromSimpleFunctionType: Boolean
Whether function references with a simple function type (e.g., Function0, KFunction0) can be converted to this family.
typeRenderingPrefix¶
abstract val typeRenderingPrefix: String?
The prefix which precedes a function type of this family when the type is rendered, such as "suspend" for the SuspendFunction family, or "@Composable" for the ComposableFunction family provided by the Compose compiler plugin.
null if types of this family are rendered without a prefix, which is the case for the Function family and for all reflection families.
Functions¶
classId¶
Returns the ClassId of the function type interface for the given arity.
For example, classId(2) on the Function family returns the ClassId for kotlin.Function2.