[NI] Minor. Change return type substitute function to not null

This commit is contained in:
Stanislav Erokhin
2017-07-07 13:14:38 +03:00
parent 2602216039
commit 9e98c11114
3 changed files with 6 additions and 6 deletions
@@ -120,7 +120,7 @@ class KotlinCallCompleter(
descriptorWithFreshTypes is PropertyDescriptor && descriptorWithFreshTypes.typeParameters.isNotEmpty() ->
// this code is very suspicious. Now it is very useful for BE, because they cannot do nothing with captured types,
// but it seems like temporary solution.
descriptorWithFreshTypes.substituteAndApproximateCapturedTypes(substitutor)!!
descriptorWithFreshTypes.substituteAndApproximateCapturedTypes(substitutor)
else ->
descriptorWithFreshTypes
}
@@ -137,7 +137,7 @@ internal object CreateDescriptorWithFreshTypeVariables : ResolutionPart {
// optimization
if (typeArgumentMappingByOriginal == NoExplicitArguments) {
descriptorWithFreshTypes = candidateDescriptor.substitute(toFreshVariables)!!
descriptorWithFreshTypes = candidateDescriptor.substitute(toFreshVariables)
csBuilder.simplify().let { assert(it.isEmpty) { "Substitutor should be empty: $it, call: $kotlinCall" } }
return emptyList()
}
@@ -166,7 +166,7 @@ internal object CreateDescriptorWithFreshTypeVariables : ResolutionPart {
*/
val toFixedTypeParameters = csBuilder.simplify()
// todo optimize -- composite substitutions before run safeSubstitute
descriptorWithFreshTypes = candidateDescriptor.substitute(toFreshVariables)!!.substitute(toFixedTypeParameters)!!
descriptorWithFreshTypes = candidateDescriptor.substitute(toFreshVariables).substitute(toFixedTypeParameters)
return emptyList()
}
@@ -36,7 +36,7 @@ val CallableDescriptor.returnTypeOrNothing: UnwrappedType
fun TypeSubstitutor.substitute(type: UnwrappedType): UnwrappedType = safeSubstitute(type, Variance.INVARIANT).unwrap()
fun CallableDescriptor.substitute(substitutor: NewTypeSubstitutor): CallableDescriptor? {
fun CallableDescriptor.substitute(substitutor: NewTypeSubstitutor): CallableDescriptor {
val wrappedSubstitution = object : TypeSubstitution() {
override fun get(key: KotlinType): TypeProjection? = null
override fun prepareTopLevelType(topLevelType: KotlinType, position: Variance) = substitutor.safeSubstitute(topLevelType.unwrap())
@@ -44,7 +44,7 @@ fun CallableDescriptor.substitute(substitutor: NewTypeSubstitutor): CallableDesc
return substitute(TypeSubstitutor.create(wrappedSubstitution))
}
fun CallableDescriptor.substituteAndApproximateCapturedTypes(substitutor: NewTypeSubstitutor): CallableDescriptor? {
fun CallableDescriptor.substituteAndApproximateCapturedTypes(substitutor: NewTypeSubstitutor): CallableDescriptor {
val wrappedSubstitution = object : TypeSubstitution() {
override fun get(key: KotlinType): TypeProjection? = null
@@ -58,4 +58,4 @@ fun CallableDescriptor.substituteAndApproximateCapturedTypes(substitutor: NewTyp
return substitute(TypeSubstitutor.create(wrappedSubstitution))
}
fun <E> MutableList<E>.trimToSize(newSize: Int) = subList(newSize, size).clear()
internal fun <E> MutableList<E>.trimToSize(newSize: Int) = subList(newSize, size).clear()