K2. Drop PostponedVariablesInitializerResolutionStage
It would be unnecessary after PCLA approach would be implemented ^KT-59791 In progress
This commit is contained in:
committed by
Space Team
parent
bb8ff9e299
commit
3b2bc49c4d
@@ -19,7 +19,6 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) {
|
|||||||
CheckContextReceivers,
|
CheckContextReceivers,
|
||||||
CheckDslScopeViolation,
|
CheckDslScopeViolation,
|
||||||
CheckLowPriorityInOverloadResolution,
|
CheckLowPriorityInOverloadResolution,
|
||||||
PostponedVariablesInitializerResolutionStage,
|
|
||||||
ProcessDynamicExtensionAnnotation,
|
ProcessDynamicExtensionAnnotation,
|
||||||
LowerPriorityIfDynamic,
|
LowerPriorityIfDynamic,
|
||||||
ConstraintSystemForks,
|
ConstraintSystemForks,
|
||||||
@@ -55,7 +54,6 @@ sealed class CallKind(vararg resolutionSequence: ResolutionStage) {
|
|||||||
CheckCallModifiers,
|
CheckCallModifiers,
|
||||||
EagerResolveOfCallableReferences,
|
EagerResolveOfCallableReferences,
|
||||||
CheckLowPriorityInOverloadResolution,
|
CheckLowPriorityInOverloadResolution,
|
||||||
PostponedVariablesInitializerResolutionStage,
|
|
||||||
ProcessDynamicExtensionAnnotation,
|
ProcessDynamicExtensionAnnotation,
|
||||||
LowerPriorityIfDynamic,
|
LowerPriorityIfDynamic,
|
||||||
ConstraintSystemForks,
|
ConstraintSystemForks,
|
||||||
@@ -126,7 +124,6 @@ class ResolutionSequenceBuilder(
|
|||||||
var checkExtensionReceiver: Boolean = false,
|
var checkExtensionReceiver: Boolean = false,
|
||||||
var checkArguments: Boolean = false,
|
var checkArguments: Boolean = false,
|
||||||
var checkLowPriorityInOverloadResolution: Boolean = false,
|
var checkLowPriorityInOverloadResolution: Boolean = false,
|
||||||
var initializePostponedVariables: Boolean = false,
|
|
||||||
var mapTypeArguments: Boolean = false,
|
var mapTypeArguments: Boolean = false,
|
||||||
var resolveCallableReferenceArguments: Boolean = false,
|
var resolveCallableReferenceArguments: Boolean = false,
|
||||||
var checkCallableReferenceExpectedType: Boolean = false,
|
var checkCallableReferenceExpectedType: Boolean = false,
|
||||||
@@ -146,7 +143,6 @@ class ResolutionSequenceBuilder(
|
|||||||
if (checkContextReceivers) add(CheckContextReceivers)
|
if (checkContextReceivers) add(CheckContextReceivers)
|
||||||
if (resolveCallableReferenceArguments) add(EagerResolveOfCallableReferences)
|
if (resolveCallableReferenceArguments) add(EagerResolveOfCallableReferences)
|
||||||
if (checkLowPriorityInOverloadResolution) add(CheckLowPriorityInOverloadResolution)
|
if (checkLowPriorityInOverloadResolution) add(CheckLowPriorityInOverloadResolution)
|
||||||
if (initializePostponedVariables) add(PostponedVariablesInitializerResolutionStage)
|
|
||||||
if (checkCallableReferenceExpectedType) add(CheckCallableReferenceExpectedType)
|
if (checkCallableReferenceExpectedType) add(CheckCallableReferenceExpectedType)
|
||||||
}.toTypedArray()
|
}.toTypedArray()
|
||||||
return CallKind.CustomForIde(*stages)
|
return CallKind.CustomForIde(*stages)
|
||||||
|
|||||||
@@ -695,59 +695,6 @@ internal object CheckIncompatibleTypeVariableUpperBounds : ResolutionStage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal object PostponedVariablesInitializerResolutionStage : ResolutionStage() {
|
|
||||||
override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) {
|
|
||||||
val argumentMapping = candidate.argumentMapping ?: return
|
|
||||||
if (candidate.typeArgumentMapping is TypeArgumentMapping.Mapped) return
|
|
||||||
|
|
||||||
val atomsToMark = mutableSetOf<FirAnonymousFunction>()
|
|
||||||
|
|
||||||
for ((argument, parameter) in argumentMapping) {
|
|
||||||
if (!parameter.hasBuilderInferenceAnnotation(context.session)) continue
|
|
||||||
val unwrapped = argument.unwrapArgument()
|
|
||||||
if (unwrapped is FirAnonymousFunctionExpression) {
|
|
||||||
atomsToMark.add(unwrapped.anonymousFunction)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO (KT-63958): This is effectively dead-code, since UseBuilderInferenceOnlyIfNeeded is always enabled
|
|
||||||
val type = parameter.returnTypeRef.coneType
|
|
||||||
val receiverType = type.receiverType(callInfo.session) ?: continue
|
|
||||||
val dontUseBuilderInferenceIfPossible =
|
|
||||||
context.session.languageVersionSettings.supportsFeature(LanguageFeature.UseBuilderInferenceOnlyIfNeeded)
|
|
||||||
if (dontUseBuilderInferenceIfPossible) continue
|
|
||||||
|
|
||||||
for (freshVariable in candidate.freshVariables) {
|
|
||||||
if (candidate.csBuilder.isPostponedTypeVariable(freshVariable)) continue
|
|
||||||
if (freshVariable !is ConeTypeParameterBasedTypeVariable) continue
|
|
||||||
val typeParameterSymbol = freshVariable.typeParameterSymbol
|
|
||||||
val typeHasVariable = receiverType.contains {
|
|
||||||
(it as? ConeTypeParameterType)?.lookupTag?.typeParameterSymbol == typeParameterSymbol
|
|
||||||
}
|
|
||||||
if (typeHasVariable) {
|
|
||||||
candidate.csBuilder.markPostponedVariable(freshVariable)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
candidate.postponedAtoms.forEach { postponedAtomContainer ->
|
|
||||||
when (postponedAtomContainer) {
|
|
||||||
is ResolvedLambdaAtom -> {
|
|
||||||
if (postponedAtomContainer.atom in atomsToMark) {
|
|
||||||
postponedAtomContainer.isCorrespondingParameterAnnotatedWithBuilderInference = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is LambdaWithTypeVariableAsExpectedTypeAtom -> {
|
|
||||||
// Although, one may annotate fun foo(@BuilderInference t: T)
|
|
||||||
// it makes little sense
|
|
||||||
}
|
|
||||||
is ResolvedCallableReferenceAtom -> {
|
|
||||||
// Builder inference doesn't apply to such atoms.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
internal object CheckCallModifiers : CheckerStage() {
|
internal object CheckCallModifiers : CheckerStage() {
|
||||||
override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) {
|
override suspend fun check(candidate: Candidate, callInfo: CallInfo, sink: CheckerSink, context: ResolutionContext) {
|
||||||
if (callInfo.callSite is FirFunctionCall) {
|
if (callInfo.callSite is FirFunctionCall) {
|
||||||
|
|||||||
Reference in New Issue
Block a user