Fix some code issue warnings
Better check for instance equality of generic types. Fixes #15100