declaration, I wish it would be allowed to have the implementation as
actual typealias xxx = yyy
, with
yyy
being an (abstract) class. Any good reason why this isn’t allowed? My use case is for example
org.w3c.dom.Node
, which is an abstract class in Kotlin/JS but an interface in Kotlin/JVM. I didn’t find an aesthetical way to bridge the two.
j
Jeff Lockhart
03/06/2023, 10:01 PM
Because Kotlin (and JS) doesn't have multiple inheritance, a class implementing the expect interface wouldn't be able to inherit from another class as well as the actual abstract class.
j
jw
03/06/2023, 10:01 PM
Suppress the error. It'll work fine.
jw
03/06/2023, 10:03 PM
It's either ACTUAL_WITHOUT_EXPECT or something else. You basically search part of the error message in the Kotlin repo to find the key to suppress
m
mkrussel
03/07/2023, 2:29 PM
That's good to know. I've run into problem with abstract vs open a lot.
j
jw
03/07/2023, 2:30 PM
Yeah I get it when using value classes in one actual but not the other, or typealiasing to a typealias. There's a lot of things that don't work but actually do when you suppress
l
Luc Girardin
03/23/2023, 9:55 AM
Many many thanks for the tip: using @Suppress(“ACTUAL_WITHOUT_EXPECT”) did the trick. Amazing that one can trick Kotlin into supporting multiple inheritance 🙂
j
Jeff Lockhart
03/23/2023, 2:57 PM
Well, it'd only be multiple inheritance if the class that implemented the expect interface also inherited from another class, in which case in Kotlin/JS it would be inheriting the actual typealias abstract class as well. As long as you're not inheriting anything else it's fine.