https://kotlinlang.org logo
#getting-started
Title
# getting-started
k

Kieran Wallbanks

06/30/2022, 9:52 AM
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

Youssef Shoaib [MOD]

06/30/2022, 9:59 AM
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

Kieran Wallbanks

06/30/2022, 10:07 AM
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

Kieran Wallbanks

06/30/2022, 10:18 AM
Would that be the same issue that causes it to fail at runtime too?
d

dmitriy.novozhilov

06/30/2022, 10:21 AM
Hm, no Issue I mentioned is only about incremental compilation Can you please create another one for your case?
k

Kieran Wallbanks

06/30/2022, 10:21 AM
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
15 Views