In the kotlin language specification, chapter 13 under the reduction phase, it is explained that when we encounter a type constraint S < T we can hit the following case
Imagine that S takes the form
G
and T takes the form
G
then the constraint would be is G < G
As described in the example, this would mean A1 takes the form out Any, and B1 takes the form out Integer.
However, now the documentation describes that this results in a type argument constraint of the from
A1 ⪯ B1
Which when both type arguments are covariant results in the constraint
A1 < B1 which in the example I propose would be Any < Integer
This would result in a constraint error. I think the relation should simply be reversed, such that the type argument constraint generated is
B1 ⪯ A1
The oracle java specification backs this proposition, as I double checked in their specification.
This confused me a lot as I was reading the definition :)
In the kotlin language specification, chapter 13 under the reduction phase, it is explained that when we encounter a type constraint S < T we can hit the following case
Imagine that S takes the form
G
and T takes the form
G
then the constraint would be is G < G
As described in the example, this would mean A1 takes the form out Any, and B1 takes the form out Integer. However, now the documentation describes that this results in a type argument constraint of the from
A1 ⪯ B1
Which when both type arguments are covariant results in the constraint
A1 < B1 which in the example I propose would be Any < Integer
This would result in a constraint error. I think the relation should simply be reversed, such that the type argument constraint generated is
B1 ⪯ A1
The oracle java specification backs this proposition, as I double checked in their specification.
This confused me a lot as I was reading the definition :)