FIR. Remove effectively unused parameter to resolveArgumentExpression

The only place where it was used was revised input type logic for lambda
analysis, and it turns out the only significant information it carries
is the presence of expected type ref, which is in fact equal to such of
an expectedType argument
This commit is contained in:
Simon Ogorodnik
2023-05-10 15:23:49 +02:00
committed by Space Team
parent 669efc781d
commit 471be7405a
6 changed files with 4 additions and 18 deletions
@@ -48,7 +48,6 @@ fun Candidate.resolveArgumentExpression(
csBuilder: ConstraintSystemBuilder,
argument: FirExpression,
expectedType: ConeKotlinType?,
expectedTypeRef: FirTypeRef?,
sink: CheckerSink,
context: ResolutionContext,
isReceiver: Boolean,
@@ -112,14 +111,13 @@ fun Candidate.resolveArgumentExpression(
else
preprocessCallableReference(argument, expectedType, context)
// TODO:!
is FirAnonymousFunctionExpression -> preprocessLambdaArgument(csBuilder, argument, expectedType, expectedTypeRef, context, sink)
is FirAnonymousFunctionExpression -> preprocessLambdaArgument(csBuilder, argument, expectedType, context, sink)
// TODO:!
//TODO: Collection literal
is FirWrappedArgumentExpression -> resolveArgumentExpression(
csBuilder,
argument.expression,
expectedType,
expectedTypeRef,
sink,
context,
isReceiver,
@@ -129,7 +127,6 @@ fun Candidate.resolveArgumentExpression(
csBuilder,
argument,
expectedType,
expectedTypeRef,
sink,
context,
isReceiver,
@@ -143,7 +140,6 @@ private fun Candidate.resolveBlockArgument(
csBuilder: ConstraintSystemBuilder,
block: FirBlock,
expectedType: ConeKotlinType?,
expectedTypeRef: FirTypeRef?,
sink: CheckerSink,
context: ResolutionContext,
isReceiver: Boolean,
@@ -169,7 +165,6 @@ private fun Candidate.resolveBlockArgument(
csBuilder,
argument,
expectedType,
expectedTypeRef,
sink,
context,
isReceiver,
@@ -450,7 +445,6 @@ internal fun Candidate.resolveArgument(
this.system.getBuilder(),
argument,
expectedType,
parameter?.returnTypeRef,
sink,
context,
isReceiver,
@@ -7,7 +7,6 @@ package org.jetbrains.kotlin.fir.resolve.inference
import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
import org.jetbrains.kotlin.fir.declarations.utils.isSuspend
import org.jetbrains.kotlin.fir.diagnostics.ConeCannotInferValueParameterType
import org.jetbrains.kotlin.fir.expressions.FirReturnExpression
import org.jetbrains.kotlin.fir.expressions.impl.FirUnitExpression
@@ -21,7 +20,6 @@ import org.jetbrains.kotlin.utils.addToStdlib.runIf
*/
fun extractLambdaInfoFromFunctionType(
expectedType: ConeKotlinType?,
expectedTypeRef: FirTypeRef?,
argument: FirAnonymousFunction,
returnTypeVariable: ConeTypeVariableForLambdaReturnType?,
components: BodyResolveComponents,
@@ -33,7 +31,6 @@ fun extractLambdaInfoFromFunctionType(
if (expectedType is ConeFlexibleType) {
return extractLambdaInfoFromFunctionType(
expectedType.lowerBound,
expectedTypeRef,
argument,
returnTypeVariable,
components,
@@ -28,13 +28,12 @@ fun Candidate.preprocessLambdaArgument(
csBuilder: ConstraintSystemBuilder,
argument: FirAnonymousFunctionExpression,
expectedType: ConeKotlinType?,
expectedTypeRef: FirTypeRef?,
context: ResolutionContext,
sink: CheckerSink?,
duringCompletion: Boolean = false,
returnTypeVariable: ConeTypeVariableForLambdaReturnType? = null
): PostponedResolvedAtom {
if (expectedType != null && expectedTypeRef != null && !duringCompletion && csBuilder.isTypeVariable(expectedType)) {
if (expectedType != null && !duringCompletion && csBuilder.isTypeVariable(expectedType)) {
val expectedTypeVariableWithConstraints = csBuilder.currentStorage().notFixedTypeVariables[expectedType.typeConstructor(context.typeContext)]
if (expectedTypeVariableWithConstraints != null) {
@@ -43,7 +42,7 @@ fun Candidate.preprocessLambdaArgument(
}?.type as ConeKotlinType?
if (explicitTypeArgument == null || explicitTypeArgument.typeArguments.isNotEmpty()) {
return LambdaWithTypeVariableAsExpectedTypeAtom(argument, expectedType, expectedTypeRef, this)
return LambdaWithTypeVariableAsExpectedTypeAtom(argument, expectedType, this)
}
}
}
@@ -53,7 +52,6 @@ fun Candidate.preprocessLambdaArgument(
val resolvedArgument =
extractLambdaInfoFromFunctionType(
expectedType,
expectedTypeRef,
anonymousFunction,
returnTypeVariable,
context.bodyResolveComponents,
@@ -194,7 +194,6 @@ class PostponedArgumentsAnalyzer(
builder,
it,
returnTypeRef.type,
returnTypeRef,
checkerSink,
context = resolutionContext,
isReceiver = false,
@@ -254,7 +253,6 @@ fun LambdaWithTypeVariableAsExpectedTypeAtom.transformToResolvedLambda(
csBuilder,
atom,
fixedExpectedType,
expectedTypeRef,
context,
sink = null,
duringCompletion = true,
@@ -88,7 +88,6 @@ class ResolvedLambdaAtom(
class LambdaWithTypeVariableAsExpectedTypeAtom(
override val atom: FirAnonymousFunctionExpression,
private val initialExpectedTypeType: ConeKotlinType,
val expectedTypeRef: FirTypeRef,
val candidateOfOuterCall: Candidate,
) : PostponedResolvedAtom(), LambdaWithTypeVariableAsExpectedTypeMarker {
init {
@@ -794,7 +794,7 @@ open class FirDeclarationsResolveTransformer(
): FirAnonymousFunction {
val resolvedLambdaAtom = (expectedTypeRef as? FirResolvedTypeRef)?.let {
extractLambdaInfoFromFunctionType(
it.type, it, anonymousFunction, returnTypeVariable = null, components, candidate = null, duringCompletion = false
it.type, anonymousFunction, returnTypeVariable = null, components, candidate = null, duringCompletion = false
)
}
var lambda = anonymousFunction