Skip to content

Commit 04ebba1

Browse files
ice-phoenixpetukhovv
authored andcommitted
Some words about suspend function types
1 parent d4024f8 commit 04ebba1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

docs/src/md/commands.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
\opMathTT{\Unit}{kotlin.Unit}
4242

4343
\opMathTT{\Function}{kotlin.Function}
44+
\opMathTT{\suspend}{suspend}
4445
\opMathTEXT{\FunctionN}{FunctionN}
4546
\opMathTEXT{\FT}{FT}
4647
\opMathTEXT{\FTR}{FTR}

docs/src/md/kotlin.core/type-system.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -696,6 +696,16 @@ Furthermore, all function types $\FunctionN$ are subtypes of a general argument-
696696
> val barRef: (Int) -> Any = Number::bar
697697
> ```
698698
699+
##### Suspend function types
700+
701+
Kotlin supports structured concurrency in the form of [coroutines] via [suspending functions].
702+
703+
For the purposes of type system, a suspending function has a *suspend* function type $\suspend \FT(A_1, \ldots, A_n) \rightarrow R$, which is **unrelated by subtyping** to any non-suspend function type.
704+
This is important for [overload resolution] and [type inference], as it directly influences the types of function values and the applicability of different functions w.r.t. overloading.
705+
706+
Most function values have either non-suspend or suspend function type based on their declarations.
707+
However, as [lambda literals] do not have any explicitely declared function type, they are considered as possibly being both non-suspend and suspend function type, with the final selection done during [type inference].
708+
699709
#### Flexible types
700710
701711
Kotlin, being a multi-platform language, needs to support transparent interoperability with platform-dependent code.

0 commit comments

Comments
 (0)