[FIR] Get rid of the argumentMapping function.
It's just a duplicate of `resolvedArgumentMapping`. Plus there is a member with the same name inside `FirAnnotationCall`.
This commit is contained in:
+2
-2
@@ -463,7 +463,7 @@ internal class KtFirCallResolver(
|
||||
val argumentMapping = if (candidate is Candidate) {
|
||||
candidate.argumentMapping
|
||||
} else {
|
||||
fir.argumentMapping
|
||||
fir.resolvedArgumentMapping
|
||||
}
|
||||
val argumentMappingWithoutExtensionReceiver =
|
||||
if (firstArgIsExtensionReceiver) {
|
||||
@@ -1119,7 +1119,7 @@ internal class KtFirCallResolver(
|
||||
}
|
||||
|
||||
private fun FirCall.createArgumentMapping(signatureOfCallee: KtFunctionLikeSignature<*>): LinkedHashMap<KtExpression, KtVariableLikeSignature<KtValueParameterSymbol>> {
|
||||
return argumentMapping?.entries.createArgumentMapping(signatureOfCallee)
|
||||
return resolvedArgumentMapping?.entries.createArgumentMapping(signatureOfCallee)
|
||||
}
|
||||
|
||||
private fun Iterable<MutableMap.MutableEntry<FirExpression, FirValueParameter>>?.createArgumentMapping(
|
||||
|
||||
+3
-3
@@ -91,7 +91,7 @@ internal class KtFirExpressionTypeProvider(
|
||||
val assignment = expression.parent as? KtBinaryExpression ?: return null
|
||||
if (assignment.operationToken !in KtTokens.ALL_ASSIGNMENTS) return null
|
||||
if (assignment.left != expression) return null
|
||||
val setTargetArgumentParameter = fir.argumentMapping?.entries?.last()?.value ?: return null
|
||||
val setTargetArgumentParameter = fir.resolvedArgumentMapping?.entries?.last()?.value ?: return null
|
||||
return setTargetArgumentParameter.returnTypeRef.coneType.asKtType()
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ internal class KtFirExpressionTypeProvider(
|
||||
return (callee.fir as FirSimpleFunction).returnTypeRef.coneType.asKtType()
|
||||
}
|
||||
|
||||
val arguments = firCall.argumentMapping ?: return null
|
||||
val arguments = firCall.resolvedArgumentMapping ?: return null
|
||||
val firParameterForExpression =
|
||||
arguments.entries.firstOrNull { (arg, _) ->
|
||||
when (arg) {
|
||||
@@ -187,7 +187,7 @@ internal class KtFirExpressionTypeProvider(
|
||||
val firCall = infixCallExpression.getOrBuildFirSafe<FirFunctionCall>(firResolveSession) ?: return null
|
||||
|
||||
// There is only one parameter for infix functions; get its type
|
||||
val arguments = firCall.argumentMapping ?: return null
|
||||
val arguments = firCall.resolvedArgumentMapping ?: return null
|
||||
val firParameterForExpression = arguments.values.singleOrNull() ?: return null
|
||||
return firParameterForExpression.returnTypeRef.coneType.asKtType()
|
||||
}
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ internal object FirAnnotationValueConverter {
|
||||
val classSymbol = resolvedSymbol.getContainingClassSymbol(session) ?: return null
|
||||
if ((classSymbol.fir as? FirClass)?.classKind == ClassKind.ANNOTATION_CLASS) {
|
||||
val resultMap = mutableMapOf<Name, FirExpression>()
|
||||
argumentMapping?.entries?.forEach { (arg, param) ->
|
||||
resolvedArgumentMapping?.entries?.forEach { (arg, param) ->
|
||||
resultMap[param.name] = arg
|
||||
}
|
||||
KtAnnotationApplicationValue(
|
||||
|
||||
+1
-1
@@ -315,7 +315,7 @@ internal object FirReferenceResolveHelper {
|
||||
}
|
||||
|
||||
private fun FirCall.findCorrespondingParameter(ktValueArgument: KtValueArgument): FirValueParameter? =
|
||||
argumentMapping?.entries?.firstNotNullOfOrNull { (firArgument, firParameter) ->
|
||||
resolvedArgumentMapping?.entries?.firstNotNullOfOrNull { (firArgument, firParameter) ->
|
||||
if (firArgument.psi == ktValueArgument) firParameter
|
||||
else null
|
||||
}
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.fir.analysis.checkers.expression.FirFunctionCallChec
|
||||
import org.jetbrains.kotlin.fir.analysis.diagnostics.jvm.FirJvmErrors
|
||||
import org.jetbrains.kotlin.fir.declarations.isJavaOrEnhancement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.argumentMapping
|
||||
import org.jetbrains.kotlin.fir.expressions.resolvedArgumentMapping
|
||||
import org.jetbrains.kotlin.fir.expressions.toResolvedCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.originalOrSelf
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.substitutorByMap
|
||||
@@ -51,7 +51,7 @@ object FirJavaGenericVarianceViolationTypeChecker : FirFunctionCallChecker() {
|
||||
if (!calleeFunction.originalOrSelf().isJavaOrEnhancement) {
|
||||
return
|
||||
}
|
||||
val argumentMapping = expression.argumentMapping ?: return
|
||||
val argumentMapping = expression.resolvedArgumentMapping ?: return
|
||||
val typeArgumentMap = mutableMapOf<FirTypeParameterSymbol, ConeKotlinType>()
|
||||
for (i in 0 until expression.typeArguments.size) {
|
||||
val type = (expression.typeArguments[i] as? FirTypeProjectionWithVariance)?.typeRef?.coneType
|
||||
|
||||
+1
-1
@@ -73,7 +73,7 @@ object FirNamedVarargChecker : FirCallChecker() {
|
||||
// FirArrayOfCall has the `vararg` argument expression pre-flattened and doesn't have an argument mapping.
|
||||
expression.arguments.forEach { checkArgument(it, it is FirNamedArgumentExpression, null /* not used for annotation call */) }
|
||||
} else {
|
||||
val argumentMap = expression.argumentMapping ?: return
|
||||
val argumentMap = expression.resolvedArgumentMapping ?: return
|
||||
for ((argument, parameter) in argumentMap) {
|
||||
if (!parameter.isVararg) continue
|
||||
if (argument is FirVarargArgumentsExpression) {
|
||||
|
||||
+1
-1
@@ -103,7 +103,7 @@ internal object FirToConstantValueTransformer : FirDefaultVisitor<ConstantValue<
|
||||
AnnotationValue(
|
||||
buildAnnotationCall {
|
||||
argumentMapping = buildAnnotationArgumentMapping {
|
||||
constructorCall.argumentMapping?.forEach { (firExpression, firValueParameter) ->
|
||||
constructorCall.resolvedArgumentMapping?.forEach { (firExpression, firValueParameter) ->
|
||||
mapping[firValueParameter.name] = firExpression
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ fun createArgumentsMapping(qualifiedAccess: FirQualifiedAccess): Map<Int, FirExp
|
||||
is FirFunctionCall -> {
|
||||
val function = qualifiedAccess.toResolvedCallableSymbol()?.fir as? FirSimpleFunction ?: return null
|
||||
val parameterToIndex = function.valueParameters.mapIndexed { index, parameter -> parameter to index }.toMap()
|
||||
val callArgumentMapping = qualifiedAccess.argumentMapping ?: return null
|
||||
val callArgumentMapping = qualifiedAccess.resolvedArgumentMapping ?: return null
|
||||
for (argument in qualifiedAccess.arguments) {
|
||||
argumentsMapping[parameterToIndex.getValue(callArgumentMapping.getValue(argument))] = argument.unwrapArgument()
|
||||
}
|
||||
|
||||
+1
-1
@@ -227,7 +227,7 @@ open class FirDeclarationsResolveTransformer(transformer: FirBodyResolveTransfor
|
||||
// var someProperty: SomeType
|
||||
// get() = delegate.getValue(thisRef, kProperty: KProperty0/1/2<..., SomeType>)
|
||||
// set() = delegate.getValue(thisRef, kProperty: KProperty0/1/2<..., SomeType>, value)
|
||||
val propertyReferenceAccess = argumentMapping?.keys?.toList()?.getOrNull(1) as? FirCallableReferenceAccess ?: return
|
||||
val propertyReferenceAccess = resolvedArgumentMapping?.keys?.toList()?.getOrNull(1) as? FirCallableReferenceAccess ?: return
|
||||
val typeRef = propertyReferenceAccess.typeRef
|
||||
if (typeRef is FirResolvedTypeRef && property.returnTypeRef is FirResolvedTypeRef) {
|
||||
val typeArguments = (typeRef.type as ConeClassLikeType).typeArguments
|
||||
|
||||
@@ -57,13 +57,7 @@ inline val FirCall.dynamicVarargArguments: List<FirExpression>?
|
||||
inline val FirFunctionCall.isCalleeDynamic: Boolean
|
||||
get() = (calleeReference.resolvedSymbol?.fir as? FirFunction)?.origin == FirDeclarationOrigin.DynamicScope
|
||||
|
||||
inline val FirCall.resolvedArgumentMapping: Map<FirExpression, FirValueParameter>?
|
||||
get() = when (val argumentList = argumentList) {
|
||||
is FirResolvedArgumentList -> argumentList.mapping
|
||||
else -> null
|
||||
}
|
||||
|
||||
inline val FirCall.argumentMapping: LinkedHashMap<FirExpression, FirValueParameter>?
|
||||
inline val FirCall.resolvedArgumentMapping: LinkedHashMap<FirExpression, FirValueParameter>?
|
||||
get() = when (val argumentList = argumentList) {
|
||||
is FirResolvedArgumentList -> argumentList.mapping
|
||||
else -> null
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.diagnostics.DiagnosticReporter
|
||||
import org.jetbrains.kotlin.diagnostics.InternalDiagnosticFactoryMethod
|
||||
import org.jetbrains.kotlin.diagnostics.reportOn
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.fir.expressions.argumentMapping
|
||||
import org.jetbrains.kotlin.fir.expressions.resolvedArgumentMapping
|
||||
import org.jetbrains.kotlin.fir.plugin.types.ConeNumberSignAttribute
|
||||
import org.jetbrains.kotlin.fir.plugin.types.numberSign
|
||||
import org.jetbrains.kotlin.fir.types.coneType
|
||||
@@ -19,7 +19,7 @@ import org.jetbrains.kotlin.fir.types.coneType
|
||||
object SignedNumberCallChecker : FirFunctionCallChecker() {
|
||||
@OptIn(InternalDiagnosticFactoryMethod::class)
|
||||
override fun check(expression: FirFunctionCall, context: CheckerContext, reporter: DiagnosticReporter) {
|
||||
val argumentMapping = expression.argumentMapping ?: return
|
||||
val argumentMapping = expression.resolvedArgumentMapping ?: return
|
||||
for ((argument, parameter) in argumentMapping.entries) {
|
||||
val expectedSign = parameter.returnTypeRef.coneType.attributes.numberSign ?: continue
|
||||
val actualSign = argument.typeRef.coneType.attributes.numberSign
|
||||
|
||||
Reference in New Issue
Block a user