NI: Fix regression for star-projections approximation

See the test added

^KT-35703 Fixed
This commit is contained in:
Denis Zharkov
2020-01-10 16:06:15 +03:00
parent 7255ee0a5b
commit 4202c9c1a4
13 changed files with 92 additions and 13 deletions
@@ -83,7 +83,10 @@ interface NewTypeSubstitutor: TypeSubstitutorMarker {
if (innerType is StubType || substitutedInnerType is StubType) {
return NewCapturedType(
capturedType.captureStatus,
NewCapturedTypeConstructor(TypeProjectionImpl(typeConstructor.projection.projectionKind, substitutedInnerType)),
NewCapturedTypeConstructor(
TypeProjectionImpl(typeConstructor.projection.projectionKind, substitutedInnerType),
typeParameter = typeConstructor.typeParameter
),
lowerType = if (capturedType.lowerType != null) substitutedInnerType else null
)
} else {
@@ -485,12 +485,14 @@ abstract class AbstractTypeApproximator(val ctx: TypeSystemInferenceExtensionCon
val argumentType = newArguments[index]?.getType() ?: argument.getType()
val capturedType = argumentType.lowerBoundIfFlexible().asCapturedType()
val capturedStarProjectionOrNull =
argumentType.lowerBoundIfFlexible().asCapturedType()?.typeConstructorProjection()?.takeIf { it.isStarProjection() }
capturedType?.typeConstructorProjection()?.takeIf { it.isStarProjection() }
if (capturedStarProjectionOrNull != null &&
(effectiveVariance == TypeVariance.OUT || effectiveVariance == TypeVariance.INV) &&
toSuper
toSuper &&
capturedType.typeParameter() == parameter
) {
newArguments[index] = capturedStarProjectionOrNull
continue@loop