Kyle Wood
11/11/2023, 11:59 PMAutoCloseable
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/Jeff Lockhart
11/12/2023, 12:08 AMAutoCloseable
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.Kyle Wood
11/12/2023, 12:12 AMJeff Lockhart
11/12/2023, 12:14 AMAutoCloseable
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.ktIt'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
.Kyle Wood
11/12/2023, 12:15 AMJeff Lockhart
11/12/2023, 12:16 AMKyle Wood
11/12/2023, 12:17 AM