[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
@@ -208,14 +208,20 @@ object StandardNames {
return "Function$parameterCount"
}
@JvmStatic
fun getFunctionClassId(parameterCount: Int): ClassId {
return ClassId(BUILT_INS_PACKAGE_FQ_NAME, Name.identifier(getFunctionName(parameterCount)))
}
@JvmStatic
fun getKFunctionFqName(parameterCount: Int): FqNameUnsafe {
return reflect(FunctionClassKind.KFunction.classNamePrefix + parameterCount)
}
@JvmStatic
fun getFunctionClassId(parameterCount: Int): ClassId {
return ClassId(BUILT_INS_PACKAGE_FQ_NAME, Name.identifier(getFunctionName(parameterCount)))
fun getKFunctionClassId(parameterCount: Int): ClassId {
val fqName = getKFunctionFqName(parameterCount)
return ClassId(fqName.parent().toSafe(), fqName.shortName())
}
@JvmStatic
@@ -228,6 +234,17 @@ object StandardNames {
return ClassId(COROUTINES_PACKAGE_FQ_NAME_RELEASE, Name.identifier(getSuspendFunctionName(parameterCount)))
}
@JvmStatic
fun getKSuspendFunctionName(parameterCount: Int): FqNameUnsafe {
return reflect(FunctionClassKind.KSuspendFunction.classNamePrefix + parameterCount)
}
@JvmStatic
fun getKSuspendFunctionClassId(parameterCount: Int): ClassId {
val fqName = getKSuspendFunctionName(parameterCount)
return ClassId(fqName.parent().toSafe(), fqName.shortName())
}
@JvmStatic
fun isPrimitiveArray(arrayFqName: FqNameUnsafe): Boolean {
return FqNames.arrayClassFqNameToPrimitiveType.get(arrayFqName) != null
@@ -193,6 +193,20 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
fun TypeVariableTypeConstructorMarker.isContainedInInvariantOrContravariantPositions(): Boolean
fun KotlinTypeMarker.isSignedOrUnsignedNumberType(): Boolean
fun KotlinTypeMarker.isFunctionOrKFunctionWithAnySuspendability(): Boolean
fun KotlinTypeMarker.isSuspendFunctionTypeOrSubtype(): Boolean
fun KotlinTypeMarker.isExtensionFunctionType(): Boolean
fun KotlinTypeMarker.extractArgumentsForFunctionalTypeOrSubtype(): List<KotlinTypeMarker>
fun KotlinTypeMarker.getFunctionalTypeFromSupertypes(): KotlinTypeMarker
fun getFunctionTypeConstructor(parametersNumber: Int, isSuspend: Boolean): TypeConstructorMarker
fun getKFunctionTypeConstructor(parametersNumber: Int, isSuspend: Boolean): TypeConstructorMarker
}