Fix incorrect inheritance loop warning in some rare cases with generics, closes #281