[FIR] Improved lambda completion: initial implementation
Repeat the logic of KotlinConstraintSystemCompleter in ConstraintSystemCompleter. Implement additional context operations required for updated lambda completion algorithm.
This commit is contained in:
+3
-36
@@ -51,26 +51,6 @@ class ClassicConstraintSystemUtilContext(
|
||||
return kotlinTypeRefiner.refineType(this)
|
||||
}
|
||||
|
||||
override fun extractFunctionalTypeFromSupertypes(type: KotlinTypeMarker): KotlinTypeMarker {
|
||||
require(type is KotlinType)
|
||||
return type.extractFunctionalTypeFromSupertypes()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.extractArgumentsForFunctionalTypeOrSubtype(): List<KotlinTypeMarker> {
|
||||
require(this is KotlinType)
|
||||
return this.getPureArgumentsForFunctionalTypeOrSubtype()
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.isFunctionOrKFunctionTypeWithAnySuspendability(): Boolean {
|
||||
require(this is KotlinType)
|
||||
return this.isFunctionOrKFunctionTypeWithAnySuspendability
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.isSuspendFunctionTypeOrSubtype(): Boolean {
|
||||
require(this is KotlinType)
|
||||
return this.isSuspendFunctionTypeOrSubtype
|
||||
}
|
||||
|
||||
override fun <T> createArgumentConstraintPosition(argument: T): ArgumentConstraintPosition<T> {
|
||||
require(argument is ResolvedAtom)
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@@ -95,22 +75,9 @@ class ClassicConstraintSystemUtilContext(
|
||||
}
|
||||
}
|
||||
|
||||
override fun KotlinTypeMarker.isExtensionFunctionType(): Boolean {
|
||||
require(this is KotlinType)
|
||||
return this.isExtensionFunctionType
|
||||
}
|
||||
|
||||
override fun getFunctionTypeConstructor(parametersNumber: Int, isSuspend: Boolean): TypeConstructorMarker {
|
||||
return getFunctionDescriptor(builtIns, parametersNumber, isSuspend).typeConstructor
|
||||
}
|
||||
|
||||
override fun getKFunctionTypeConstructor(parametersNumber: Int, isSuspend: Boolean): TypeConstructorMarker {
|
||||
return getKFunctionDescriptor(builtIns, parametersNumber, isSuspend).typeConstructor
|
||||
}
|
||||
|
||||
override fun isAnonymousFunction(argument: PostponedAtomWithRevisableExpectedType): Boolean {
|
||||
require(argument is ResolvedAtom)
|
||||
return argument.atom is FunctionExpression
|
||||
override fun PostponedAtomWithRevisableExpectedType.isAnonymousFunction(): Boolean {
|
||||
require(this is ResolvedAtom)
|
||||
return this.atom is FunctionExpression
|
||||
}
|
||||
|
||||
override fun PostponedAtomWithRevisableExpectedType.isFunctionExpressionWithReceiver(): Boolean {
|
||||
|
||||
+2
-2
@@ -150,9 +150,9 @@ class KotlinConstraintSystemCompleter(
|
||||
c: ConstraintSystemCompletionContext,
|
||||
argument: PostponedAtomWithRevisableExpectedType,
|
||||
diagnosticsHolder: KotlinDiagnosticsHolder
|
||||
): Boolean = with(ctx) {
|
||||
): Boolean = with(c) {
|
||||
val revisedExpectedType: UnwrappedType =
|
||||
argument.revisedExpectedType?.takeIf { it.isFunctionOrKFunctionTypeWithAnySuspendability() }?.cast() ?: return false
|
||||
argument.revisedExpectedType?.takeIf { it.isFunctionOrKFunctionWithAnySuspendability() }?.cast() ?: return false
|
||||
|
||||
when (argument) {
|
||||
is PostponedCallableReferenceAtom ->
|
||||
|
||||
@@ -212,8 +212,7 @@ class CallableReferenceWithRevisedExpectedTypeAtom(
|
||||
class PostponedCallableReferenceAtom(
|
||||
eagerCallableReferenceAtom: EagerCallableReferenceAtom
|
||||
) : AbstractPostponedCallableReferenceAtom(eagerCallableReferenceAtom.atom, eagerCallableReferenceAtom.expectedType),
|
||||
PostponedCallableReferenceMarker,
|
||||
PostponedAtomWithRevisableExpectedType
|
||||
PostponedCallableReferenceMarker
|
||||
{
|
||||
override var revisedExpectedType: UnwrappedType? = null
|
||||
private set
|
||||
|
||||
Reference in New Issue
Block a user