Make freshly substituted type variables def not nullable if they come from not null type parameter

^KT-48778 Fixed
This commit is contained in:
Victor Petukhov
2021-10-06 18:42:35 +03:00
parent 02d06b6390
commit 836c6b280d
12 changed files with 80 additions and 14 deletions
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.descriptors.annotations.CompositeAnnotations
import org.jetbrains.kotlin.resolve.calls.inference.isCaptured
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableFromCallableDescriptor
import org.jetbrains.kotlin.resolve.calls.inference.model.TypeVariableTypeConstructor
import org.jetbrains.kotlin.resolve.calls.inference.substitute
import org.jetbrains.kotlin.types.*
import org.jetbrains.kotlin.types.checker.NewCapturedType
@@ -157,7 +158,11 @@ interface NewTypeSubstitutor : TypeSubstitutorMarker {
replacement = replacement.makeDefinitelyNotNullOrNotNull()
}
if (type is CustomTypeParameter) {
replacement = type.substitutionResult(replacement).unwrap()
replacement = type.substitutionResult(replacement).unwrap().run {
if (type is NotNullTypeVariable && replacement.constructor is TypeVariableTypeConstructor) {
makeDefinitelyNotNullOrNotNull()
} else this
}
}
return replacement