[NI] Approximate intersection type in type argument to star if it's necessary
#KT-32196 Fixed
This commit is contained in:
@@ -510,6 +510,24 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon
|
||||
}
|
||||
} ?: continue@loop
|
||||
|
||||
if (
|
||||
conf.intersection != ALLOWED &&
|
||||
effectiveVariance == TypeVariance.OUT &&
|
||||
argumentType.typeConstructor().isIntersection()
|
||||
) {
|
||||
var shouldReplaceWithStar = false
|
||||
for (upperBoundIndex in 0 until parameter.upperBoundCount()) {
|
||||
if (!AbstractTypeChecker.isSubtypeOf(ctx, approximatedArgument, parameter.getUpperBound(upperBoundIndex))) {
|
||||
shouldReplaceWithStar = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (shouldReplaceWithStar) {
|
||||
newArguments[index] = createStarProjection(parameter)
|
||||
continue@loop
|
||||
}
|
||||
}
|
||||
|
||||
if (parameter.getVariance() == TypeVariance.INV) {
|
||||
newArguments[index] = createTypeArgument(approximatedArgument, effectiveVariance)
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user