[FIR] Get rid of inference components in CheckerSink
This commit is contained in:
@@ -78,7 +78,8 @@ fun Candidate.resolveArgumentExpression(
|
|||||||
SimpleConstraintSystemConstraintPosition,
|
SimpleConstraintSystemConstraintPosition,
|
||||||
isReceiver = false,
|
isReceiver = false,
|
||||||
isDispatch = false,
|
isDispatch = false,
|
||||||
sink = sink
|
sink = sink,
|
||||||
|
context = context
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +143,8 @@ private fun Candidate.resolveBlockArgument(
|
|||||||
SimpleConstraintSystemConstraintPosition,
|
SimpleConstraintSystemConstraintPosition,
|
||||||
isReceiver = false,
|
isReceiver = false,
|
||||||
isDispatch = false,
|
isDispatch = false,
|
||||||
sink = sink
|
sink = sink,
|
||||||
|
context = context
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -187,7 +189,7 @@ fun Candidate.resolveSubCallArgument(
|
|||||||
val type: ConeKotlinType = if (candidate.symbol.fir is FirIntegerOperator) {
|
val type: ConeKotlinType = if (candidate.symbol.fir is FirIntegerOperator) {
|
||||||
(argument as FirFunctionCall).resultType.coneType
|
(argument as FirFunctionCall).resultType.coneType
|
||||||
} else {
|
} else {
|
||||||
sink.components.returnTypeCalculator.tryCalculateReturnType(candidate.symbol.firUnsafe()).type
|
context.returnTypeCalculator.tryCalculateReturnType(candidate.symbol.firUnsafe()).type
|
||||||
}
|
}
|
||||||
val argumentType = candidate.substitutor.substituteOrSelf(type)
|
val argumentType = candidate.substitutor.substituteOrSelf(type)
|
||||||
resolvePlainArgumentType(csBuilder, argumentType, expectedType, sink, context, isReceiver, isDispatch, useNullableArgumentType)
|
resolvePlainArgumentType(csBuilder, argumentType, expectedType, sink, context, isReceiver, isDispatch, useNullableArgumentType)
|
||||||
@@ -228,7 +230,7 @@ fun Candidate.resolvePlainArgumentType(
|
|||||||
) {
|
) {
|
||||||
val position = SimpleConstraintSystemConstraintPosition //TODO
|
val position = SimpleConstraintSystemConstraintPosition //TODO
|
||||||
|
|
||||||
val session = sink.components.session
|
val session = context.session
|
||||||
val capturedType = prepareCapturedType(argumentType, context)
|
val capturedType = prepareCapturedType(argumentType, context)
|
||||||
|
|
||||||
val argumentTypeForApplicabilityCheck =
|
val argumentTypeForApplicabilityCheck =
|
||||||
@@ -238,7 +240,7 @@ fun Candidate.resolvePlainArgumentType(
|
|||||||
capturedType
|
capturedType
|
||||||
|
|
||||||
checkApplicabilityForArgumentType(
|
checkApplicabilityForArgumentType(
|
||||||
csBuilder, argumentTypeForApplicabilityCheck, expectedType, position, isReceiver, isDispatch, sink
|
csBuilder, argumentTypeForApplicabilityCheck, expectedType, position, isReceiver, isDispatch, sink, context
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +273,8 @@ private fun checkApplicabilityForArgumentType(
|
|||||||
position: SimpleConstraintSystemConstraintPosition,
|
position: SimpleConstraintSystemConstraintPosition,
|
||||||
isReceiver: Boolean,
|
isReceiver: Boolean,
|
||||||
isDispatch: Boolean,
|
isDispatch: Boolean,
|
||||||
sink: CheckerSink
|
sink: CheckerSink,
|
||||||
|
context: ResolutionContext
|
||||||
) {
|
) {
|
||||||
if (expectedType == null) return
|
if (expectedType == null) return
|
||||||
if (isReceiver && isDispatch) {
|
if (isReceiver && isDispatch) {
|
||||||
@@ -286,7 +289,7 @@ private fun checkApplicabilityForArgumentType(
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val nullableExpectedType = expectedType.withNullability(ConeNullability.NULLABLE, sink.components.session.typeContext)
|
val nullableExpectedType = expectedType.withNullability(ConeNullability.NULLABLE, context.session.typeContext)
|
||||||
|
|
||||||
if (csBuilder.addSubtypeConstraintIfCompatible(argumentType, nullableExpectedType, position)) {
|
if (csBuilder.addSubtypeConstraintIfCompatible(argumentType, nullableExpectedType, position)) {
|
||||||
sink.reportDiagnostic(InapplicableWrongReceiver) // TODO
|
sink.reportDiagnostic(InapplicableWrongReceiver) // TODO
|
||||||
@@ -305,9 +308,9 @@ internal fun Candidate.resolveArgument(
|
|||||||
context: ResolutionContext
|
context: ResolutionContext
|
||||||
) {
|
) {
|
||||||
|
|
||||||
argument.resultType.ensureResolvedTypeDeclaration(sink.components.session)
|
argument.resultType.ensureResolvedTypeDeclaration(context.session)
|
||||||
|
|
||||||
val expectedType = prepareExpectedType(sink.components.session, argument, parameter, context)
|
val expectedType = prepareExpectedType(context.session, argument, parameter, context)
|
||||||
resolveArgumentExpression(
|
resolveArgumentExpression(
|
||||||
this.system.getBuilder(),
|
this.system.getBuilder(),
|
||||||
argument,
|
argument,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
package org.jetbrains.kotlin.fir.resolve.calls
|
package org.jetbrains.kotlin.fir.resolve.calls
|
||||||
|
|
||||||
import org.jetbrains.kotlin.fir.PrivateForInline
|
import org.jetbrains.kotlin.fir.PrivateForInline
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.InferenceComponents
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
||||||
import org.jetbrains.kotlin.resolve.calls.tower.isSuccess
|
import org.jetbrains.kotlin.resolve.calls.tower.isSuccess
|
||||||
import kotlin.coroutines.Continuation
|
import kotlin.coroutines.Continuation
|
||||||
@@ -14,8 +13,6 @@ import kotlin.coroutines.Continuation
|
|||||||
abstract class CheckerSink {
|
abstract class CheckerSink {
|
||||||
abstract fun reportDiagnostic(diagnostic: ResolutionDiagnostic)
|
abstract fun reportDiagnostic(diagnostic: ResolutionDiagnostic)
|
||||||
|
|
||||||
abstract val components: InferenceComponents
|
|
||||||
|
|
||||||
abstract val needYielding: Boolean
|
abstract val needYielding: Boolean
|
||||||
|
|
||||||
@PrivateForInline
|
@PrivateForInline
|
||||||
@@ -35,7 +32,6 @@ suspend inline fun CheckerSink.yieldDiagnostic(diagnostic: ResolutionDiagnostic)
|
|||||||
}
|
}
|
||||||
|
|
||||||
class CheckerSinkImpl(
|
class CheckerSinkImpl(
|
||||||
override val components: InferenceComponents,
|
|
||||||
var continuation: Continuation<Unit>? = null,
|
var continuation: Continuation<Unit>? = null,
|
||||||
val stopOnFirstError: Boolean = true
|
val stopOnFirstError: Boolean = true
|
||||||
) : CheckerSink() {
|
) : CheckerSink() {
|
||||||
|
|||||||
+1
-1
@@ -73,7 +73,7 @@ internal object CreateFreshTypeVariableSubstitutorStage : ResolutionStage() {
|
|||||||
is FirStarProjection -> csBuilder.addEqualityConstraint(
|
is FirStarProjection -> csBuilder.addEqualityConstraint(
|
||||||
freshVariable.defaultType,
|
freshVariable.defaultType,
|
||||||
typeParameter.symbol.fir.bounds.firstOrNull()?.coneType
|
typeParameter.symbol.fir.bounds.firstOrNull()?.coneType
|
||||||
?: sink.components.session.builtinTypes.nullableAnyType.type,
|
?: context.session.builtinTypes.nullableAnyType.type,
|
||||||
SimpleConstraintSystemConstraintPosition
|
SimpleConstraintSystemConstraintPosition
|
||||||
)
|
)
|
||||||
else -> assert(typeArgument == FirTypePlaceholderProjection) {
|
else -> assert(typeArgument == FirTypePlaceholderProjection) {
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@ import kotlin.coroutines.resume
|
|||||||
|
|
||||||
class ResolutionStageRunner(private val context: ResolutionContext) {
|
class ResolutionStageRunner(private val context: ResolutionContext) {
|
||||||
fun processCandidate(candidate: Candidate, stopOnFirstError: Boolean = true): CandidateApplicability {
|
fun processCandidate(candidate: Candidate, stopOnFirstError: Boolean = true): CandidateApplicability {
|
||||||
val sink = CheckerSinkImpl(context.bodyResolveComponents.inferenceComponents, stopOnFirstError = stopOnFirstError)
|
val sink = CheckerSinkImpl(stopOnFirstError = stopOnFirstError)
|
||||||
var finished = false
|
var finished = false
|
||||||
sink.continuation = suspend {
|
sink.continuation = suspend {
|
||||||
candidate.callInfo.callKind.resolutionSequence.forEachIndexed { index, stage ->
|
candidate.callInfo.callKind.resolutionSequence.forEachIndexed { index, stage ->
|
||||||
|
|||||||
+1
-1
@@ -151,7 +151,7 @@ class PostponedArgumentsAnalyzer(
|
|||||||
|
|
||||||
returnArguments.forEach { c.addSubsystemFromExpression(it) }
|
returnArguments.forEach { c.addSubsystemFromExpression(it) }
|
||||||
|
|
||||||
val checkerSink: CheckerSink = CheckerSinkImpl(components)
|
val checkerSink: CheckerSink = CheckerSinkImpl()
|
||||||
|
|
||||||
var hasExpressionInReturnArguments = false
|
var hasExpressionInReturnArguments = false
|
||||||
returnArguments.forEach {
|
returnArguments.forEach {
|
||||||
|
|||||||
Reference in New Issue
Block a user