diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt index 539d9d222a7..b4399c7ebc3 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/KotlinCallCompleter.kt @@ -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 } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt index e4feb509648..4b0485b348d 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/components/ResolutionParts.kt @@ -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() } diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt index 35d84b708f4..6d1415d61fa 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/InferenceUtils.kt @@ -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 MutableList.trimToSize(newSize: Int) = subList(newSize, size).clear() \ No newline at end of file +internal fun MutableList.trimToSize(newSize: Int) = subList(newSize, size).clear() \ No newline at end of file