== How to fix it

The code can be improved by adding the `sealed` keyword in front of the `class` or `record` types that have no inheritors.