https://kotlinlang.org logo
g

Grigorii Yurkov

03/07/2021, 4:34 PM
What is the lowest common ancestor of
Array<Int>
and
Array<in Int>
? In my opinion it should be
Array<in Int>
. But kotlin compiler thinks it's
Array<out Int?>
. I agree that
Array<out Int?>
is supertype of both
Array<Int>
and
Array<in Int>
, but it's not the lowest. What do you think?
i

ilya.gorbunov

03/09/2021, 5:04 AM
I agree it should be
Array<in Int>
, so in this case the type inference seems to be not inferring the most specific supertype. I've opened https://youtrack.jetbrains.com/issue/KT-45362 to track this problem, feel free to vote or star it to follow the updates on it.