[FIR] Consistently use _function_ instead of _functional_ in names of classes and functions
This commit is contained in:
committed by
Space Team
parent
f268ab8858
commit
89c42e20c9
@@ -6,7 +6,7 @@
|
||||
package org.jetbrains.kotlin.builtins
|
||||
|
||||
import org.jetbrains.kotlin.builtins.StandardNames.FqNames.reflect
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionalTypeKind
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.FqNameUnsafe
|
||||
@@ -252,7 +252,7 @@ object StandardNames {
|
||||
|
||||
@JvmStatic
|
||||
fun getKFunctionFqName(parameterCount: Int): FqNameUnsafe {
|
||||
return reflect(FunctionalTypeKind.KFunction.classNamePrefix + parameterCount)
|
||||
return reflect(FunctionTypeKind.KFunction.classNamePrefix + parameterCount)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -263,7 +263,7 @@ object StandardNames {
|
||||
|
||||
@JvmStatic
|
||||
fun getSuspendFunctionName(parameterCount: Int): String {
|
||||
return FunctionalTypeKind.SuspendFunction.classNamePrefix + parameterCount
|
||||
return FunctionTypeKind.SuspendFunction.classNamePrefix + parameterCount
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@@ -273,7 +273,7 @@ object StandardNames {
|
||||
|
||||
@JvmStatic
|
||||
fun getKSuspendFunctionName(parameterCount: Int): FqNameUnsafe {
|
||||
return reflect(FunctionalTypeKind.KSuspendFunction.classNamePrefix + parameterCount)
|
||||
return reflect(FunctionTypeKind.KSuspendFunction.classNamePrefix + parameterCount)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
|
||||
+21
-21
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
|
||||
/**
|
||||
* [FunctionalTypeKind] describes a family of various similar functional types (like kotlin.FunctionN)
|
||||
* [FunctionTypeKind] describes a family of various similar functional types (like kotlin.FunctionN)
|
||||
* All types in the same family have corresponding shape of classId: [packageFqName].[classNamePrefix]N,
|
||||
* where `N` is an arity of function
|
||||
*
|
||||
@@ -38,7 +38,7 @@ import org.jetbrains.kotlin.name.Name
|
||||
* Note that if you provide some new functional type kind it's your responsibility to handle all references to it in backend
|
||||
* with [IrGenerationExtension] implementation
|
||||
*/
|
||||
abstract class FunctionalTypeKind internal constructor(
|
||||
abstract class FunctionTypeKind internal constructor(
|
||||
val packageFqName: FqName,
|
||||
val classNamePrefix: String,
|
||||
val isReflectType: Boolean,
|
||||
@@ -69,7 +69,7 @@ abstract class FunctionalTypeKind internal constructor(
|
||||
*
|
||||
* Should be overridden for reflect kinds
|
||||
*/
|
||||
open fun nonReflectKind(): FunctionalTypeKind {
|
||||
open fun nonReflectKind(): FunctionTypeKind {
|
||||
return if (isReflectType) error("Should be overridden explicitly") else this
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ abstract class FunctionalTypeKind internal constructor(
|
||||
*
|
||||
* Should be overridden for non reflect kinds
|
||||
*/
|
||||
open fun reflectKind(): FunctionalTypeKind {
|
||||
open fun reflectKind(): FunctionTypeKind {
|
||||
return if (isReflectType) this else error("Should be overridden explicitly")
|
||||
}
|
||||
|
||||
@@ -93,16 +93,16 @@ abstract class FunctionalTypeKind internal constructor(
|
||||
|
||||
// ------------------------------------------- Builtin functional kinds -------------------------------------------
|
||||
|
||||
object Function : FunctionalTypeKind(
|
||||
object Function : FunctionTypeKind(
|
||||
StandardNames.BUILT_INS_PACKAGE_FQ_NAME,
|
||||
"Function",
|
||||
isReflectType = false,
|
||||
annotationOnInvokeClassId = null
|
||||
) {
|
||||
override fun reflectKind(): FunctionalTypeKind = KFunction
|
||||
override fun reflectKind(): FunctionTypeKind = KFunction
|
||||
}
|
||||
|
||||
object SuspendFunction : FunctionalTypeKind(
|
||||
object SuspendFunction : FunctionTypeKind(
|
||||
StandardNames.COROUTINES_PACKAGE_FQ_NAME,
|
||||
"SuspendFunction",
|
||||
isReflectType = false,
|
||||
@@ -111,39 +111,39 @@ abstract class FunctionalTypeKind internal constructor(
|
||||
override val prefixForTypeRender: String
|
||||
get() = "suspend"
|
||||
|
||||
override fun reflectKind(): FunctionalTypeKind = KSuspendFunction
|
||||
override fun reflectKind(): FunctionTypeKind = KSuspendFunction
|
||||
}
|
||||
|
||||
object KFunction : FunctionalTypeKind(
|
||||
object KFunction : FunctionTypeKind(
|
||||
StandardNames.KOTLIN_REFLECT_FQ_NAME,
|
||||
"KFunction",
|
||||
isReflectType = true,
|
||||
annotationOnInvokeClassId = null
|
||||
) {
|
||||
override fun nonReflectKind(): FunctionalTypeKind = Function
|
||||
override fun nonReflectKind(): FunctionTypeKind = Function
|
||||
}
|
||||
|
||||
object KSuspendFunction : FunctionalTypeKind(
|
||||
object KSuspendFunction : FunctionTypeKind(
|
||||
StandardNames.KOTLIN_REFLECT_FQ_NAME,
|
||||
"KSuspendFunction",
|
||||
isReflectType = true,
|
||||
annotationOnInvokeClassId = null
|
||||
) {
|
||||
override fun nonReflectKind(): FunctionalTypeKind = SuspendFunction
|
||||
override fun nonReflectKind(): FunctionTypeKind = SuspendFunction
|
||||
}
|
||||
}
|
||||
|
||||
val FunctionalTypeKind.isBuiltin: Boolean
|
||||
val FunctionTypeKind.isBuiltin: Boolean
|
||||
get() = when (this) {
|
||||
FunctionalTypeKind.Function,
|
||||
FunctionalTypeKind.SuspendFunction,
|
||||
FunctionalTypeKind.KFunction,
|
||||
FunctionalTypeKind.KSuspendFunction -> true
|
||||
FunctionTypeKind.Function,
|
||||
FunctionTypeKind.SuspendFunction,
|
||||
FunctionTypeKind.KFunction,
|
||||
FunctionTypeKind.KSuspendFunction -> true
|
||||
else -> false
|
||||
}
|
||||
|
||||
val FunctionalTypeKind.isSuspendType: Boolean
|
||||
get() = this.nonReflectKind() == FunctionalTypeKind.SuspendFunction
|
||||
val FunctionTypeKind.isSuspendOrKSuspendFunction: Boolean
|
||||
get() = this.nonReflectKind() == FunctionTypeKind.SuspendFunction
|
||||
|
||||
val FunctionalTypeKind.isRegularFunction: Boolean
|
||||
get() = this.nonReflectKind() == FunctionalTypeKind.Function
|
||||
val FunctionTypeKind.isBasicFunctionOrKFunction: Boolean
|
||||
get() = this.nonReflectKind() == FunctionTypeKind.Function
|
||||
+8
-8
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
@RequiresOptIn
|
||||
annotation class AllowedToUsedOnlyInK1
|
||||
|
||||
class FunctionalTypeKindExtractor(kinds: List<FunctionalTypeKind>) {
|
||||
class FunctionTypeKindExtractor(kinds: List<FunctionTypeKind>) {
|
||||
companion object {
|
||||
/**
|
||||
* This instance should be used only in:
|
||||
@@ -19,19 +19,19 @@ class FunctionalTypeKindExtractor(kinds: List<FunctionalTypeKind>) {
|
||||
*/
|
||||
@JvmStatic
|
||||
@AllowedToUsedOnlyInK1
|
||||
val Default = FunctionalTypeKindExtractor(
|
||||
val Default = FunctionTypeKindExtractor(
|
||||
listOf(
|
||||
FunctionalTypeKind.Function,
|
||||
FunctionalTypeKind.SuspendFunction,
|
||||
FunctionalTypeKind.KFunction,
|
||||
FunctionalTypeKind.KSuspendFunction,
|
||||
FunctionTypeKind.Function,
|
||||
FunctionTypeKind.SuspendFunction,
|
||||
FunctionTypeKind.KFunction,
|
||||
FunctionTypeKind.KSuspendFunction,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private val knownKindsByPackageFqName = kinds.groupBy { it.packageFqName }
|
||||
|
||||
fun getFunctionalClassKind(packageFqName: FqName, className: String): FunctionalTypeKind? {
|
||||
fun getFunctionalClassKind(packageFqName: FqName, className: String): FunctionTypeKind? {
|
||||
return getFunctionalClassKindWithArity(packageFqName, className)?.kind
|
||||
}
|
||||
|
||||
@@ -49,7 +49,7 @@ class FunctionalTypeKindExtractor(kinds: List<FunctionalTypeKind>) {
|
||||
return packageFqName in knownKindsByPackageFqName
|
||||
}
|
||||
|
||||
data class KindWithArity(val kind: FunctionalTypeKind, val arity: Int)
|
||||
data class KindWithArity(val kind: FunctionTypeKind, val arity: Int)
|
||||
|
||||
private fun toInt(s: String): Int? {
|
||||
if (s.isEmpty()) return null
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.types.model
|
||||
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionalTypeKind
|
||||
import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind
|
||||
import org.jetbrains.kotlin.resolve.checkers.EmptyIntersectionTypeChecker
|
||||
import org.jetbrains.kotlin.resolve.checkers.EmptyIntersectionTypeInfo
|
||||
import org.jetbrains.kotlin.types.*
|
||||
@@ -165,7 +165,7 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
|
||||
|
||||
fun KotlinTypeMarker.isUnit(): Boolean
|
||||
|
||||
fun KotlinTypeMarker.isBuiltinFunctionalTypeOrSubtype(): Boolean
|
||||
fun KotlinTypeMarker.isBuiltinFunctionTypeOrSubtype(): Boolean
|
||||
|
||||
fun createCapturedType(
|
||||
constructorProjection: TypeArgumentMarker,
|
||||
@@ -252,17 +252,17 @@ interface TypeSystemInferenceExtensionContext : TypeSystemContext, TypeSystemBui
|
||||
|
||||
fun KotlinTypeMarker.isFunctionOrKFunctionWithAnySuspendability(): Boolean
|
||||
|
||||
fun KotlinTypeMarker.functionalTypeKind(): FunctionalTypeKind?
|
||||
fun KotlinTypeMarker.functionTypeKind(): FunctionTypeKind?
|
||||
|
||||
fun KotlinTypeMarker.isExtensionFunctionType(): Boolean
|
||||
|
||||
fun KotlinTypeMarker.extractArgumentsForFunctionalTypeOrSubtype(): List<KotlinTypeMarker>
|
||||
fun KotlinTypeMarker.extractArgumentsForFunctionTypeOrSubtype(): List<KotlinTypeMarker>
|
||||
|
||||
fun KotlinTypeMarker.getFunctionalTypeFromSupertypes(): KotlinTypeMarker
|
||||
fun KotlinTypeMarker.getFunctionTypeFromSupertypes(): KotlinTypeMarker
|
||||
|
||||
fun getNonReflectFunctionTypeConstructor(parametersNumber: Int, kind: FunctionalTypeKind): TypeConstructorMarker
|
||||
fun getNonReflectFunctionTypeConstructor(parametersNumber: Int, kind: FunctionTypeKind): TypeConstructorMarker
|
||||
|
||||
fun getReflectFunctionTypeConstructor(parametersNumber: Int, kind: FunctionalTypeKind): TypeConstructorMarker
|
||||
fun getReflectFunctionTypeConstructor(parametersNumber: Int, kind: FunctionTypeKind): TypeConstructorMarker
|
||||
|
||||
// -------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user