Is it possible to implement an `expect` class in J...
# multiplatform
j
Is it possible to implement an
expect
class in JVM with a property
path
and the extending class has a method
getPath()
? (I'm talking about
File
class). I'm trying something like
actual class MyFile extends <http://java.io|java.io>.File
and MyFile has a property
path
.
e
i think that works if it’s a typealias instead of an extends
actual typealias MyFile = <http://java.io|java.io>.File
j
That would work if the methods weren't a little bit different and I wasn't able to create actual extension methods to that typealias
e
best i could come up with:
Copy code
actual class MyFile(pathname: String) : File(pathname) {
  actual val myPath: String
    get() = path
}
couldn’t get around the “accidental override” if the name is the same
j
That's what I came up with, and one can't override getPath as it's final, I wouldn't like to call it mypath as it works everywhere and I wouldn't like to have a backing object as that means 2 objects every time it is instantiated but it seems is what I'll have to do
I would be fine if I found a synonym for path, lol