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

Marcin Wisniowski

10/11/2023, 9:20 AM
Is this a known IDE bug? I’m told the when case is not exhaustive, but the missing branch was already handled. If I do add the branch, I get a different error that the branch is unreachable, so there is no way to make the IDE happy.
p

Priyabrata Naskar

10/11/2023, 9:28 AM
Make it sealed class or you can use class outside of sealed interface & there you can implement
m

Marcin Wisniowski

10/11/2023, 9:33 AM
Yes there are many ways to workaround it, but it doesn’t change the fact it’s a bug.
😅 1
h

hho

10/11/2023, 9:53 AM
I don't think it's strictly a bug, more like a missing feature: The compiler just isn't smart enough to figure out that the cases not handled in the
if
are enough to make the
when
exhaustive. And TBH, if I saw this code in a review, I would tell you to use either an
if
or a
when
here, but not both…
m

Marcin Wisniowski

10/11/2023, 9:57 AM
This is a minimal example which makes using both
if
and
when
useless. The real code needs it.
> I don't think it's strictly a bug, more like a missing feature That's a fair explanation for the first error, but then the second lint error is a bug: it suggests to remove a branch, and applying the fix makes the code (that was working) no longer compile.
a

ascii

10/11/2023, 10:09 AM
Lint errors should not be ignored, but warnings can and very well should be suppressed in such cases
Dunno if there's already a bug filed for this
Yes, it can be suppressed, but it's not ideal since you cannot suppress it for just one case, so you lose the lint warnings on all cases, where they could be real issues.
m

Marcin Wisniowski

10/11/2023, 10:44 AM
Thanks, added as a comment on my issue
o

okarm

10/11/2023, 3:09 PM
What is the
new *
source annotation in the screenshot?
Oh, nevermind, it's the VCS author, isn't it?
👌 2
4 Views