If I have a common library which targets the `Auto...
# multiplatform
k
If I have a common library which targets the
AutoCloseable
experimental stdlib API, is there a way to make it also work for JVM? I get a type mismatch error when trying to use a Java
AutoCloseable
with my library https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-auto-closeable/
j
AutoCloseable
is an
expect class
in Kotlin common and its JVM
actual
is the Java implementation. If you're getting an error, it's likely a false positive in the IDE.
k
Yup, you're right. It builds and the test executes fine, it's an IDE error
j
I use
AutoCloseable
in my KMP library and in some cases it works as expected, while in other cases, I get this error in the IDE for the JVM actual class:
Actual class 'SomeClass' has no corresponding expected declaration
The following declaration is incompatible because some supertypes are missing in the actual declaration:
@OptIn public final expect class SomeClass : AutoCloseable defined in somepackage in file SomeClass.kt
It's odd because it's pretty much the same scenario as others that don't display an error in the IDE, an
expect class
that implements
AutoCloseable
.
k
I'll open an issue on youtrack about it, hopefully my particular issue is simple enough to be fixed, I haven't run into that one yet though
j
Great. I'll add my error to the issue. I haven't created one for this yet.
k
Alright cool - I'll push up my reproduction example to a git repo and create the issue, I'll drop the link in here once I've done that
👍🏼 1