Backports library changes related to SI-6566 from a419799

The idea of backporting this occured while developing the -source flag
for SI-8126 : withouth this the library breaks at refchecks for a
Scala compiler that checks type aliases variance.

This shoudl be BC and promote good hygiene.
Merge pull request #3359 from huitseeker/issue/VarianceAdaptations

[backport] Backports library changes related to SI-6566 from a419799