KT-6393 Smart completion of anonymous object inserts type with "!" for type parameter

#KT-6393 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-05-08 11:36:30 +03:00
parent 833d474876
commit ce3492f270
14 changed files with 104 additions and 58 deletions
@@ -47,13 +47,21 @@ public fun approximateFlexibleTypes(jetType: JetType, outermost: Boolean = true)
// Foo<(Mutable)Collection<T>!>! -> Foo<Collection<T>>?
// Foo! -> Foo?
// Foo<Bar!>! -> Foo<Bar>?
val approximation =
var approximation =
if (isCollection)
TypeUtils.makeNullableAsSpecified(if (jetType.isMarkedReadOnly()) flexible.upperBound else flexible.lowerBound, outermost)
else
if (outermost) flexible.upperBound else flexible.lowerBound
val approximated = approximateFlexibleTypes(approximation)
return if (jetType.isMarkedNotNull()) approximated.makeNotNullable() else approximated
approximation = approximateFlexibleTypes(approximation)
approximation = if (jetType.isMarkedNotNull()) approximation.makeNotNullable() else approximation
if (approximation.isMarkedNullable() && !flexible.lowerBound.isMarkedNullable() && TypeUtils.isTypeParameter(approximation) && TypeUtils.hasNullableSuperType(approximation)) {
approximation = approximation.makeNotNullable()
}
return approximation
}
return JetTypeImpl(
jetType.getAnnotations(),