bug: Invert cast and downcast