<@U0D06TWMA> using `when` on an instance of `Speci...
# announcements
d
@Andreas Sinz using
when
on an instance of
SpecificExceptions
the auto-completion for all branches at least doesn’t work
a
@damian with all branches you mean
ErrorOne
and
ErrorTwo
?
d
yes, it’s only giving me
ErrorTwo
as possibility
a
if you have an instance of
SpecificExcetpions
, it cannot be an instance of
ErrorOne
?
d
at least thats what the auto-completion of the
when
branches is telling me; also red-underine with “incompatible types”
a
but its not possible with ordinary classes too?
d
what do you mean?
a
ErrorOne
is not a subclass of
SpecificExceptions
, so an instance of
SpecificExceptions
can not be
ErrorOne
d
yes that is true. that’s why i was thinking / asking if there’s a way to extend sealed classes, or to inherit the collection of classes in a sealed class and add new ones in another class
a
Extending sealed classes is not possible, because that would make sealed classes useless
you could create something like
class SpecificBaseException(val exception: BaseException)
d
hmm. i’ll see if i can make it work for my use-case. thanks