[FIR2IR] Remove argument unwrapping for SAM conversion
FirNamedArgumentExpressions don't exist anymore during FIR2IR phase and so we don't need to unwrap arguments here anymore. #KT-66124
This commit is contained in:
committed by
Space Team
parent
015f257031
commit
fbb21f2406
+7
-10
@@ -43,8 +43,6 @@ import org.jetbrains.kotlin.ir.expressions.impl.*
|
|||||||
import org.jetbrains.kotlin.ir.symbols.*
|
import org.jetbrains.kotlin.ir.symbols.*
|
||||||
import org.jetbrains.kotlin.ir.types.*
|
import org.jetbrains.kotlin.ir.types.*
|
||||||
import org.jetbrains.kotlin.ir.util.dump
|
import org.jetbrains.kotlin.ir.util.dump
|
||||||
import org.jetbrains.kotlin.ir.util.isPrimitiveArray
|
|
||||||
import org.jetbrains.kotlin.ir.util.isUnsignedArray
|
|
||||||
import org.jetbrains.kotlin.ir.util.render
|
import org.jetbrains.kotlin.ir.util.render
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator.commonSuperType
|
import org.jetbrains.kotlin.resolve.calls.NewCommonSuperTypeCalculator.commonSuperType
|
||||||
@@ -1045,12 +1043,11 @@ class CallAndReferenceGenerator(
|
|||||||
// In this case we have to use parameter type itself which is more precise, like Array<String> or IntArray.
|
// In this case we have to use parameter type itself which is more precise, like Array<String> or IntArray.
|
||||||
// See KT-62598 and its fix for details.
|
// See KT-62598 and its fix for details.
|
||||||
val expectedType = unsubstitutedParameterType.takeIf { visitor.annotationMode && unsubstitutedParameterType?.isArrayType == true }
|
val expectedType = unsubstitutedParameterType.takeIf { visitor.annotationMode && unsubstitutedParameterType?.isArrayType == true }
|
||||||
val unwrappedArgument = argument.unwrapArgument()
|
var irArgument = visitor.convertToIrExpression(argument, expectedType = expectedType)
|
||||||
var irArgument = visitor.convertToIrExpression(unwrappedArgument, expectedType = expectedType)
|
|
||||||
if (unsubstitutedParameterType != null) {
|
if (unsubstitutedParameterType != null) {
|
||||||
with(visitor.implicitCastInserter) {
|
with(visitor.implicitCastInserter) {
|
||||||
val argumentType = unwrappedArgument.resolvedType.fullyExpandedType(session)
|
val argumentType = argument.resolvedType.fullyExpandedType(session)
|
||||||
if (unwrappedArgument is FirSmartCastExpression) {
|
if (argument is FirSmartCastExpression) {
|
||||||
val substitutedParameterType = substitutor.substituteOrSelf(unsubstitutedParameterType)
|
val substitutedParameterType = substitutor.substituteOrSelf(unsubstitutedParameterType)
|
||||||
// here we should use a substituted parameter type to properly choose the component of an intersection type
|
// here we should use a substituted parameter type to properly choose the component of an intersection type
|
||||||
// to provide a proper cast to the smartcasted type
|
// to provide a proper cast to the smartcasted type
|
||||||
@@ -1058,7 +1055,7 @@ class CallAndReferenceGenerator(
|
|||||||
}
|
}
|
||||||
// here we should pass unsubstituted parameter type to properly infer if the original type accepts null or not
|
// here we should pass unsubstituted parameter type to properly infer if the original type accepts null or not
|
||||||
// to properly insert nullability check
|
// to properly insert nullability check
|
||||||
irArgument = irArgument.insertSpecialCast(unwrappedArgument, argumentType, unsubstitutedParameterType)
|
irArgument = irArgument.insertSpecialCast(argument, argumentType, unsubstitutedParameterType)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
with(adapterGenerator) {
|
with(adapterGenerator) {
|
||||||
@@ -1067,12 +1064,12 @@ class CallAndReferenceGenerator(
|
|||||||
val parameterType = parameter.returnTypeRef.coneType
|
val parameterType = parameter.returnTypeRef.coneType
|
||||||
val unwrappedParameterType = if (parameter.isVararg) parameterType.arrayElementType()!! else parameterType
|
val unwrappedParameterType = if (parameter.isVararg) parameterType.arrayElementType()!! else parameterType
|
||||||
val samFunctionType = getFunctionTypeForPossibleSamType(unwrappedParameterType)
|
val samFunctionType = getFunctionTypeForPossibleSamType(unwrappedParameterType)
|
||||||
irArgument = irArgument.applySuspendConversionIfNeeded(unwrappedArgument, samFunctionType ?: unwrappedParameterType)
|
irArgument = irArgument.applySuspendConversionIfNeeded(argument, samFunctionType ?: unwrappedParameterType)
|
||||||
irArgument = irArgument.applySamConversionIfNeeded(unwrappedArgument, parameter)
|
irArgument = irArgument.applySamConversionIfNeeded(argument, parameter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return irArgument
|
return irArgument
|
||||||
.applyImplicitIntegerCoercionIfNeeded(unwrappedArgument, parameter)
|
.applyImplicitIntegerCoercionIfNeeded(argument, parameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun IrExpression.applyImplicitIntegerCoercionIfNeeded(
|
private fun IrExpression.applyImplicitIntegerCoercionIfNeeded(
|
||||||
|
|||||||
Reference in New Issue
Block a user