BS-10295
Improve return type compatibility algoritm