fixed exception in ModelCode::validateBaseClass

fixes #3009