Do not return star-projections during approximation

See comment in test for clarification

 #KT-14453 Fixed
This commit is contained in:
Denis Zharkov
2016-11-30 17:10:47 +03:00
parent b8e1ce7a05
commit cbebb06574
4 changed files with 44 additions and 1 deletions
@@ -86,7 +86,11 @@ fun approximateCapturedTypesIfNecessary(typeProjection: TypeProjection?, approxi
private fun substituteCapturedTypesWithProjections(typeProjection: TypeProjection): TypeProjection? {
val typeSubstitutor = TypeSubstitutor.create(object : TypeConstructorSubstitution() {
override fun get(key: TypeConstructor): TypeProjection? {
return (key as? CapturedTypeConstructor)?.typeProjection
val capturedTypeConstructor = key as? CapturedTypeConstructor ?: return null
if (capturedTypeConstructor.typeProjection.isStarProjection) {
return TypeProjectionImpl(Variance.OUT_VARIANCE, capturedTypeConstructor.typeProjection.type)
}
return capturedTypeConstructor.typeProjection
}
})
return typeSubstitutor.substituteWithoutApproximation(typeProjection)