05nelsonm / kmp-file

A very simple File API for Kotlin Multiplatform. It gets the job done.
Apache License 2.0
2 stars 0 forks source link

Java has trouble resolving `File` because use of `JvmName` annotation #32

Closed 05nelsonm closed 8 months ago

05nelsonm commented 8 months ago
class Builder {
    var directory: File? = null
}
class Testing {
    private void testIt() {
        Builder b = new Builder();
        b.directory = java.io.File("/som/path"); // <<<<< shows error
        b.directory = io.matthewnelson.kmp.file.File.get("/some/path"); // <<<< IDE error
    }
}

This is because commonMain the File.kt file is annotated with JvmName("File") such that in Java land, directory is expecting io.matthewnelson.kmp.file.File and not the typealias

Removing the JvmName annotation would allow for the following from Java and present no errors.

class Testing {
    private void testIt() {
        Builder b = new Builder();
        b.directory = FileKt.get("/some/path");
    }
}