Okay I know you can have sealed classes for a when check to verify that you are covering all branches.
is the reverse possible say given a string input I output all sealed classes under a hirachy? I'm guessing no the type checker can't verify
g
ghedeon
01/21/2020, 6:27 PM
what is the meaning behind "string input"? There is
::class.sealedSubclasses
if that's what are you looking for
h
Hanno
01/21/2020, 7:17 PM
Ha! Hesitated to ask that question Yesterday xD my usecase was as Well that i got object input and wanted to verify that if the given input CAN be parsed it will be parsed correctly.
Thats what I mean by string the variable type is a string. The classes "PercentageFee" etc are in a sealed hirachy. Basically I would like if someone adds to the hirachy to know to find this piece of code and add to it. i.e. all possible branches are covered.
s
Sergei Dubrov [JB]
01/22/2020, 9:28 AM
Kotlin has exhaustiveness check for enums and sealed classes only. Is it possible to solve this with enum?