Hi, is it possible to have different return type f...
# multiplatform
g
Hi, is it possible to have different return type for
actual
function? For example, here is the expected function
Copy code
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
Copy code
public actual fun FilePicker(
	onFileSelected: (MPFile<Any>?) -> Unit
)
because of this on the calling site it requires a cast.
Copy code
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
Copy code
public actual fun FilePicker(
	onFileSelected: (MPFile<File>?) -> Unit, // I want something like this but it says: "Actual function 'FilePicker' has no corresponding expected declaration"
)
a
Maybe
expect class PlatformFile
, with
actual typealias PlatformFile = java.io.File
?
☝️ 4