Issue #22151 was coincidentally fixed in commit aed1974e (`Refactor the treatment of loopy superclass dicts`). This adds a regression test to ensure that the issue remains fixed. Fixes #22151.