[NI] Minor. Change return type substitute function to not null
This commit is contained in:
+1
-1
@@ -120,7 +120,7 @@ class KotlinCallCompleter(
|
|||||||
descriptorWithFreshTypes is PropertyDescriptor && descriptorWithFreshTypes.typeParameters.isNotEmpty() ->
|
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,
|
// 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.
|
// but it seems like temporary solution.
|
||||||
descriptorWithFreshTypes.substituteAndApproximateCapturedTypes(substitutor)!!
|
descriptorWithFreshTypes.substituteAndApproximateCapturedTypes(substitutor)
|
||||||
else ->
|
else ->
|
||||||
descriptorWithFreshTypes
|
descriptorWithFreshTypes
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -137,7 +137,7 @@ internal object CreateDescriptorWithFreshTypeVariables : ResolutionPart {
|
|||||||
|
|
||||||
// optimization
|
// optimization
|
||||||
if (typeArgumentMappingByOriginal == NoExplicitArguments) {
|
if (typeArgumentMappingByOriginal == NoExplicitArguments) {
|
||||||
descriptorWithFreshTypes = candidateDescriptor.substitute(toFreshVariables)!!
|
descriptorWithFreshTypes = candidateDescriptor.substitute(toFreshVariables)
|
||||||
csBuilder.simplify().let { assert(it.isEmpty) { "Substitutor should be empty: $it, call: $kotlinCall" } }
|
csBuilder.simplify().let { assert(it.isEmpty) { "Substitutor should be empty: $it, call: $kotlinCall" } }
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
@@ -166,7 +166,7 @@ internal object CreateDescriptorWithFreshTypeVariables : ResolutionPart {
|
|||||||
*/
|
*/
|
||||||
val toFixedTypeParameters = csBuilder.simplify()
|
val toFixedTypeParameters = csBuilder.simplify()
|
||||||
// todo optimize -- composite substitutions before run safeSubstitute
|
// todo optimize -- composite substitutions before run safeSubstitute
|
||||||
descriptorWithFreshTypes = candidateDescriptor.substitute(toFreshVariables)!!.substitute(toFixedTypeParameters)!!
|
descriptorWithFreshTypes = candidateDescriptor.substitute(toFreshVariables).substitute(toFixedTypeParameters)
|
||||||
|
|
||||||
return emptyList()
|
return emptyList()
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -36,7 +36,7 @@ val CallableDescriptor.returnTypeOrNothing: UnwrappedType
|
|||||||
|
|
||||||
fun TypeSubstitutor.substitute(type: UnwrappedType): UnwrappedType = safeSubstitute(type, Variance.INVARIANT).unwrap()
|
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() {
|
val wrappedSubstitution = object : TypeSubstitution() {
|
||||||
override fun get(key: KotlinType): TypeProjection? = null
|
override fun get(key: KotlinType): TypeProjection? = null
|
||||||
override fun prepareTopLevelType(topLevelType: KotlinType, position: Variance) = substitutor.safeSubstitute(topLevelType.unwrap())
|
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))
|
return substitute(TypeSubstitutor.create(wrappedSubstitution))
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CallableDescriptor.substituteAndApproximateCapturedTypes(substitutor: NewTypeSubstitutor): CallableDescriptor? {
|
fun CallableDescriptor.substituteAndApproximateCapturedTypes(substitutor: NewTypeSubstitutor): CallableDescriptor {
|
||||||
val wrappedSubstitution = object : TypeSubstitution() {
|
val wrappedSubstitution = object : TypeSubstitution() {
|
||||||
override fun get(key: KotlinType): TypeProjection? = null
|
override fun get(key: KotlinType): TypeProjection? = null
|
||||||
|
|
||||||
@@ -58,4 +58,4 @@ fun CallableDescriptor.substituteAndApproximateCapturedTypes(substitutor: NewTyp
|
|||||||
return substitute(TypeSubstitutor.create(wrappedSubstitution))
|
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()
|
||||||
Reference in New Issue
Block a user