[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:
Pavel Kirpichenkov
2020-09-30 16:07:03 +03:00
parent 5eae6f2f4e
commit 712a2ce1ab
35 changed files with 614 additions and 368 deletions
@@ -5,10 +5,8 @@
package org.jetbrains.kotlin.types.checker
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.builtins.*
import org.jetbrains.kotlin.builtins.StandardNames.FqNames
import org.jetbrains.kotlin.builtins.isBuiltinFunctionalTypeOrSubtype
import org.jetbrains.kotlin.descriptors.*
import org.jetbrains.kotlin.descriptors.annotations.AnnotationDescriptor
import org.jetbrains.kotlin.descriptors.annotations.Annotations
@@ -674,6 +672,39 @@ interface ClassicTypeSystemContext : TypeSystemInferenceExtensionContext, TypeSy
} ?: error("Expected intersection type, found $firstCandidate")
}
override fun KotlinTypeMarker.isFunctionOrKFunctionWithAnySuspendability(): Boolean {
require(this is KotlinType, this::errorMessage)
return this.isFunctionOrKFunctionTypeWithAnySuspendability
}
override fun KotlinTypeMarker.isSuspendFunctionTypeOrSubtype(): Boolean {
require(this is KotlinType, this::errorMessage)
return this.isSuspendFunctionTypeOrSubtype
}
override fun KotlinTypeMarker.isExtensionFunctionType(): Boolean {
require(this is KotlinType, this::errorMessage)
return this.isExtensionFunctionType
}
override fun KotlinTypeMarker.extractArgumentsForFunctionalTypeOrSubtype(): List<KotlinTypeMarker> {
require(this is KotlinType, this::errorMessage)
return this.getPureArgumentsForFunctionalTypeOrSubtype()
}
override fun KotlinTypeMarker.getFunctionalTypeFromSupertypes(): KotlinTypeMarker {
require(this is KotlinType)
return this.extractFunctionalTypeFromSupertypes()
}
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
}
}
fun TypeVariance.convertVariance(): Variance {