https://kotlinlang.org logo
Title
a

araqnid

04/29/2018, 1:05 AM
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

Andreas Sinz

04/29/2018, 8:52 AM
exactly
a

araqnid

04/29/2018, 2:13 PM
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

Andreas Sinz

04/30/2018, 11:59 AM
The problem is that
Comparator<T>
is defined in the java stdlib, so kotlin is unable to change that