FIR: use captureFromTypeParameterUpperBoundIfNeeded for argument types

#KT-48161 Fixed
This commit is contained in:
Mikhail Glukhikh
2021-08-09 12:19:49 +03:00
parent 73a8b4544a
commit a04913a197
7 changed files with 58 additions and 4 deletions
@@ -31,7 +31,6 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
import org.jetbrains.kotlin.resolve.calls.inference.addSubtypeConstraintIfCompatible
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
import org.jetbrains.kotlin.types.AbstractTypeChecker
import org.jetbrains.kotlin.types.SmartcastStability
import org.jetbrains.kotlin.types.model.CaptureStatus
import org.jetbrains.kotlin.types.model.TypeSystemCommonSuperTypesContext
import org.jetbrains.kotlin.utils.addToStdlib.runIf
@@ -347,7 +346,7 @@ fun isArgumentTypeMismatchDueToNullability(
private fun checkApplicabilityForArgumentType(
csBuilder: ConstraintSystemBuilder,
argument: FirExpression,
argumentType: ConeKotlinType,
argumentTypeBeforeCapturing: ConeKotlinType,
expectedType: ConeKotlinType?,
position: SimpleConstraintSystemConstraintPosition,
isReceiver: Boolean,
@@ -357,6 +356,9 @@ private fun checkApplicabilityForArgumentType(
) {
if (expectedType == null) return
// todo run this approximation only once for call
val argumentType = captureFromTypeParameterUpperBoundIfNeeded(argumentTypeBeforeCapturing, expectedType, context.session)
fun subtypeError(actualExpectedType: ConeKotlinType): ResolutionDiagnostic {
if (argument.isNullLiteral && actualExpectedType.nullability == ConeNullability.NOT_NULL) {
return NullForNotNullType(argument)