Giorgi
01/01/2024, 8:42 PMactual function?
For example, here is the expected function
public interface MPFile<out T : Any> {
public val path: String
public val platformFile: T
}
public expect fun FilePicker(
onFileSelected: (MPFile<Any>?) -> Unit
)
In JVM it looks like this, I can return java.io.File, but the argument has to be Any
public actual fun FilePicker(
onFileSelected: (MPFile<Any>?) -> Unit
)
because of this on the calling site it requires a cast.
FilePicker(showSingleFile, fileExtensions = listOf("jpg", "png")) { file ->
file?.platformFile as File // platform file type is Any and needs to be cast to File
}
Is it possible to have something like this for JVM? so that it will not be required to be cast to java.io.File
public actual fun FilePicker(
onFileSelected: (MPFile<File>?) -> Unit, // I want something like this but it says: "Actual function 'FilePicker' has no corresponding expected declaration"
)Arkadii Ivanov
01/01/2024, 9:14 PMexpect class PlatformFile, with actual typealias PlatformFile = java.io.File?