After approximation interpret Contr<*> as Contr<Nothing>
not Contr<out Any?>
This commit is contained in:
@@ -8,4 +8,4 @@ fun foo<T>(a: Contr<T>) {}
|
|||||||
|
|
||||||
// T captures 'out Int'
|
// T captures 'out Int'
|
||||||
// lower: Contr<Int>
|
// lower: Contr<Int>
|
||||||
// upper: Contr<out Any?>
|
// upper: Contr<Nothing>
|
||||||
|
|||||||
@@ -58,7 +58,8 @@ private fun TypeArgument.toTypeProjection(): TypeProjection {
|
|||||||
fun removeProjectionIfRedundant(variance: Variance) = if (variance == typeParameter.getVariance()) Variance.INVARIANT else variance
|
fun removeProjectionIfRedundant(variance: Variance) = if (variance == typeParameter.getVariance()) Variance.INVARIANT else variance
|
||||||
return when {
|
return when {
|
||||||
inProjection == outProjection -> TypeProjectionImpl(inProjection)
|
inProjection == outProjection -> TypeProjectionImpl(inProjection)
|
||||||
inProjection == NOTHING || inProjection == NULLABLE_NOTHING -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.OUT_VARIANCE), outProjection)
|
(inProjection == NOTHING || inProjection == NULLABLE_NOTHING) && typeParameter.getVariance() != Variance.IN_VARIANCE ->
|
||||||
|
TypeProjectionImpl(removeProjectionIfRedundant(Variance.OUT_VARIANCE), outProjection)
|
||||||
outProjection == NULLABLE_ANY -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.IN_VARIANCE), inProjection)
|
outProjection == NULLABLE_ANY -> TypeProjectionImpl(removeProjectionIfRedundant(Variance.IN_VARIANCE), inProjection)
|
||||||
else -> throw AssertionError("Enhanced type projection can't be converted to type projection: $this")
|
else -> throw AssertionError("Enhanced type projection can't be converted to type projection: $this")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user