Fix yet another bug in 'deriving' for polykinded classes (Trac #7269)

This patch makes the code a bit simpler if anything.

(cherry picked from commit b1436f55da2b0e005ac09be6651a2c4d934027ec)
Add missing test file T7269

(cherry picked from commit db869e7521387db0513d1dc2b49641ce32688cdd)