Has anyone been having issues using sealed classes...
# getting-started
k
Has anyone been having issues using sealed classes/interfaces in Kotlin 1.7? I seem to constantly get runtime issues with classes throwing exceptions saying things like "X can't extend sealed class" when it has worked fine before. Plus compile-time issues where exhaustive when statements will break, saying they need an else when they definitely don't. They get fixed by doing completely clean builds so I was wondering if maybe there's an issue with compilation? I'm using the incremental kotlin compiler with classpath snapshots - could this be an issue with that?
y
For in-ide errors make sure your Kotlin plugin is up to date. Keep in mind that AFAIK some complex usages of sealed interfaces are just simply not understood by the exhaustiveness checker and so you will have to begrudgingly add an else.
k
Not getting any IDE errors - and it's not related to complexity either as the code compiles fine most of the time, it just breaks occasionally
k
Would that be the same issue that causes it to fail at runtime too?
d
Hm, no Issue I mentioned is only about incremental compilation Can you please create another one for your case?
k
Sure, I'll open an issue whenever it happens again. Very rare to occur though, I can't manage to reproduce it reliably at all
🙏 1