xxfast
04/07/2022, 3:35 AM// commonMain
expect class Pager
// androidMain
actual typealias Pager = PagerState
Feels weird that you can expect a class and have it actualised by a type aliasAnton Lakotka [JB]
04/07/2022, 6:57 AM// commonMain.kt
expect class Pager
fun foo(pager: Pager) { println(pager) }
// androidMain.kt
actual typealias Pager = PagerState
When compilation for android is requested through ./gradlew build
for example.
Kotlin compiler will receive as input both source files. roughly like this: kotlinc src/commonMain.kt src/androidMain.kt
Compiler will scan all files and will try to match all expects and actuals. And if its all right, it internally makes your code look like this:
// internal representation
fun foo(pager: Pager) { println(pager) }
typealias Pager = PagerState
this is perfectly valid code.
Hope this helps you to understand the logic behind expect/actual.xxfast
04/21/2022, 5:00 AM