Why doesn’t the T of `Comparator<T>` have in...
# announcements
a
Why doesn’t the T of
Comparator<T>
have input variance? I was trying to assign a Collator (which for some reason is a
Comparator<Object>
in Java) to
Comparator<String>
. Is it because it’s simply a typealias?
a
exactly
a
although it being a typealias is just a platform concern-- it does feel like it should be <in T> in stdlib-common. I can work around with
Comparator(collator::compare)
though
a
The problem is that
Comparator<T>
is defined in the java stdlib, so kotlin is unable to change that