From 6c377aa69f57ac085be4467b736410bf54d15608 Mon Sep 17 00:00:00 2001 From: Igor Chevdar Date: Fri, 2 Aug 2019 14:33:45 +0300 Subject: [PATCH] Made [K][Suspend]FunctionN autogenerated --- ...BuiltInFictitiousFunctionIrClassFactory.kt | 194 ++++++++++++++++++ .../kotlin/backend/konan/KonanFqNames.kt | 7 +- .../konan/TopDownAnalyzerFacadeForKonan.kt | 13 +- .../kotlin/backend/konan/ToplevelPhases.kt | 18 +- .../kotlin/backend/konan/cgen/CBridgeGen.kt | 2 +- .../kotlin/backend/konan/injection.kt | 8 +- .../jetbrains/kotlin/backend/konan/ir/Ir.kt | 26 ++- .../llvm/objcexport/BlockPointerSupport.kt | 7 +- .../objcexport/ObjCExportCodeGenerator.kt | 10 +- .../konan/lower/CallableReferenceLowering.kt | 8 +- .../konan/objcexport/ObjCExportMapper.kt | 4 - .../backend/konan/optimizations/DFGBuilder.kt | 5 +- .../KonanDeserializeDescriptorReference.kt | 31 +-- .../konan/serialization/KonanIrlinker.kt | 7 +- ...DeserializedModuleDescriptorFactoryImpl.kt | 13 +- runtime/src/main/kotlin/kotlin/Functions.kt | 98 --------- .../kotlin/coroutines/SuspendFunctions.kt | 98 --------- .../main/kotlin/kotlin/reflect/KFunctions.kt | 55 ----- .../kotlin/reflect/KSuspendFunctions.kt | 59 ------ 19 files changed, 273 insertions(+), 390 deletions(-) create mode 100644 backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt delete mode 100644 runtime/src/main/kotlin/kotlin/Functions.kt delete mode 100644 runtime/src/main/kotlin/kotlin/coroutines/SuspendFunctions.kt delete mode 100644 runtime/src/main/kotlin/kotlin/reflect/KFunctions.kt delete mode 100644 runtime/src/main/kotlin/kotlin/reflect/KSuspendFunctions.kt diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt new file mode 100644 index 00000000000..f751d494662 --- /dev/null +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/BuiltInFictitiousFunctionIrClassFactory.kt @@ -0,0 +1,194 @@ +/* + * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the LICENSE file. + */ + +package org.jetbrains.kotlin.backend.konan + +import org.jetbrains.kotlin.backend.common.ir.* +import org.jetbrains.kotlin.backend.konan.descriptors.findPackage +import org.jetbrains.kotlin.builtins.functions.FunctionClassDescriptor +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.declarations.impl.* +import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns +import org.jetbrains.kotlin.ir.symbols.IrSymbol +import org.jetbrains.kotlin.ir.symbols.impl.IrClassSymbolImpl +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.classOrNull +import org.jetbrains.kotlin.ir.types.defaultType +import org.jetbrains.kotlin.ir.types.impl.IrSimpleTypeImpl +import org.jetbrains.kotlin.ir.types.impl.makeTypeProjection +import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.util.OperatorNameConventions + +internal object DECLARATION_ORIGIN_FUNCTION_CLASS : IrDeclarationOriginImpl("DECLARATION_ORIGIN_FUNCTION_CLASS") + +internal class BuiltInFictitiousFunctionIrClassFactory( + var symbolTable: SymbolTable?, + private val irBuiltIns: IrBuiltIns, + private val reflectionTypes: KonanReflectionTypes +) : IrProvider { + + override fun getDeclaration(symbol: IrSymbol) = + (symbol.descriptor as? FunctionClassDescriptor)?.let { buildClass(it) } + + var module: IrModuleFragment? = null + set(value) { + if (value == null) + error("Provide a valid non-null module") + if (field != null) + error("Module has already been set") + field = value + value.files += filesMap.values + builtClasses.forEach { it.addFakeOverrides() } + } + + class FunctionalInterface(val irClass: IrClass, val arity: Int) + + fun function(n: Int) = buildClass(irBuiltIns.builtIns.getFunction(n) as FunctionClassDescriptor) + fun kFunction(n: Int) = buildClass(reflectionTypes.getKFunction(n) as FunctionClassDescriptor) + fun suspendFunction(n: Int) = buildClass(irBuiltIns.builtIns.getSuspendFunction(n) as FunctionClassDescriptor) + fun kSuspendFunction(n: Int) = buildClass(reflectionTypes.getKSuspendFunction(n) as FunctionClassDescriptor) + + private val functionSymbol = symbolTable!!.referenceClass( + irBuiltIns.builtIns.builtInsModule.findClassAcrossModuleDependencies( + ClassId.topLevel(KonanFqNames.function))!!) + + private val kFunctionSymbol = symbolTable!!.referenceClass( + irBuiltIns.builtIns.builtInsModule.findClassAcrossModuleDependencies( + ClassId.topLevel(KonanFqNames.kFunction))!!) + + private val filesMap = mutableMapOf() + + private val builtClassesMap = mutableMapOf() + + val builtClasses get() = builtClassesMap.values + + val builtFunctionNClasses get() = + builtClassesMap.values + .filter { (it.descriptor as FunctionClassDescriptor).functionKind == FunctionClassDescriptor.Kind.Function } + .map { FunctionalInterface(it, (it.descriptor as FunctionClassDescriptor).arity) } + + private fun createTypeParameter(descriptor: TypeParameterDescriptor) = + symbolTable?.declareGlobalTypeParameter( + SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, DECLARATION_ORIGIN_FUNCTION_CLASS, + descriptor + ) + ?: IrTypeParameterImpl( + SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, DECLARATION_ORIGIN_FUNCTION_CLASS, + descriptor + ) + + private fun createSimpleFunction( + descriptor: FunctionDescriptor, + origin: IrDeclarationOrigin, + returnType: IrType + ) = symbolTable?.declareSimpleFunction( + SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, origin, + descriptor + ) { + IrFunctionImpl( + SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, origin, + it, + returnType + ) + } + ?: IrFunctionImpl( + SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, origin, + descriptor, + returnType + ) + + private fun createClass(descriptor: FunctionClassDescriptor) = + symbolTable?.declareClass( + SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, DECLARATION_ORIGIN_FUNCTION_CLASS, + descriptor + ) + ?: IrClassImpl( + SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, DECLARATION_ORIGIN_FUNCTION_CLASS, + IrClassSymbolImpl(descriptor) + ) + + private fun buildClass(descriptor: FunctionClassDescriptor): IrClass = + builtClassesMap.getOrPut(descriptor) { + createClass(descriptor).apply { + val functionClass = this + descriptor.declaredTypeParameters.mapTo(typeParameters) { typeParameterDescriptor -> + createTypeParameter(typeParameterDescriptor).also { + it.parent = this + it.superTypes += irBuiltIns.anyNType + } + } + + val descriptorToIrParametersMap = typeParameters.map { it.descriptor to it }.toMap() + descriptor.typeConstructor.supertypes.mapTo(superTypes) { superType -> + val arguments = superType.arguments.map { argument -> + val argumentClassifierDescriptor = argument.type.constructor.declarationDescriptor + val argumentClassifierSymbol = argumentClassifierDescriptor?.let { descriptorToIrParametersMap[it] } + ?: error("Unexpected super type argument: $argumentClassifierDescriptor") + makeTypeProjection(argumentClassifierSymbol.defaultType, argument.projectionKind) + } + val superTypeSymbol = when (val superTypeDescriptor = superType.constructor.declarationDescriptor) { + is FunctionClassDescriptor -> buildClass(superTypeDescriptor).symbol + functionSymbol.descriptor -> functionSymbol + kFunctionSymbol.descriptor -> kFunctionSymbol + else -> error("Unexpected super type: $superTypeDescriptor") + } + IrSimpleTypeImpl(superTypeSymbol, superType.isMarkedNullable, arguments, emptyList()) + } + + createParameterDeclarations() + + val invokeFunctionDescriptor = descriptor.unsubstitutedMemberScope.getContributedFunctions( + OperatorNameConventions.INVOKE, NoLookupLocation.FROM_BACKEND).single() + val isFakeOverride = invokeFunctionDescriptor.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE + val invokeFunctionOrigin = + if (isFakeOverride) + IrDeclarationOrigin.FAKE_OVERRIDE + else + DECLARATION_ORIGIN_FUNCTION_CLASS + declarations += createSimpleFunction( + invokeFunctionDescriptor, invokeFunctionOrigin, + typeParameters.last().defaultType + ).apply { + parent = functionClass + invokeFunctionDescriptor.valueParameters.mapTo(valueParameters) { + IrValueParameterImpl( + SYNTHETIC_OFFSET, SYNTHETIC_OFFSET, + invokeFunctionOrigin, + it, + functionClass.typeParameters[it.index].defaultType, + null + ).also { it.parent = this } + } + if (!isFakeOverride) + createDispatchReceiverParameter(invokeFunctionOrigin) + else { + val overriddenFunction = superTypes + .mapNotNull { it.classOrNull?.owner } + .single { it.descriptor is FunctionClassDescriptor } + .simpleFunctions() + .single { it.name == OperatorNameConventions.INVOKE } + overriddenSymbols += overriddenFunction.symbol + dispatchReceiverParameter = overriddenFunction.dispatchReceiverParameter?.copyTo(this) + } + } + // Unfortunately, addFakeOverrides() uses some parents but they are only set after PsiToIr phase. + // So we add all the fake overrides only when we're supplied with the module (this is done after PsiToIr). + if (this@BuiltInFictitiousFunctionIrClassFactory.module != null) + addFakeOverrides() + + val packageFragmentDescriptor = descriptor.findPackage() + val file = filesMap.getOrPut(packageFragmentDescriptor) { + IrFileImpl(NaiveSourceBasedFileEntryImpl("[K][Suspend]Functions"), packageFragmentDescriptor).also { + this@BuiltInFictitiousFunctionIrClassFactory.module?.files?.add(it) + } + } + parent = file + file.declarations += this + } + } +} \ No newline at end of file diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanFqNames.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanFqNames.kt index eebb61a32da..837e1995820 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanFqNames.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/KonanFqNames.kt @@ -13,6 +13,8 @@ internal const val NATIVE_PTR_NAME = "NativePtr" internal const val NON_NULL_NATIVE_PTR_NAME = "NonNullNativePtr" object KonanFqNames { + val function = FqName("kotlin.Function") + val kFunction = FqName("kotlin.reflect.KFunction") val packageName = FqName("kotlin.native") val internalPackageName = FqName("kotlin.native.internal") val nativePtr = internalPackageName.child(Name.identifier(NATIVE_PTR_NAME)).toUnsafe() @@ -24,8 +26,3 @@ object KonanFqNames { val typedIntrinsic = FqName("kotlin.native.internal.TypedIntrinsic") val objCMethod = FqName("kotlinx.cinterop.ObjCMethod") } - -/** - * Maximum number of parameters supported in function types (e.g. `FunctionXX`, `KFunctionXX`, `SuspendFunctionXX`). - */ -internal const val KONAN_FUNCTION_INTERFACES_MAX_PARAMETERS = 22 diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/TopDownAnalyzerFacadeForKonan.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/TopDownAnalyzerFacadeForKonan.kt index 5b8910a2d64..3737f83c989 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/TopDownAnalyzerFacadeForKonan.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/TopDownAnalyzerFacadeForKonan.kt @@ -7,12 +7,14 @@ package org.jetbrains.kotlin.backend.konan import org.jetbrains.kotlin.analyzer.AnalysisResult import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.builtins.functions.functionInterfacePackageFragmentProvider import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.get import org.jetbrains.kotlin.context.ModuleContext import org.jetbrains.kotlin.context.MutableModuleContextImpl import org.jetbrains.kotlin.context.ProjectContext +import org.jetbrains.kotlin.descriptors.PackageFragmentProvider import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.descriptors.konan.CurrentKonanModuleOrigin import org.jetbrains.kotlin.descriptors.konan.isKonanStdlib @@ -47,22 +49,26 @@ internal object TopDownAnalyzerFacadeForKonan { config.languageVersionSettings, config.friendModuleFiles) + val additionalPackages = mutableListOf() if (!module.isKonanStdlib()) { val dependencies = listOf(module) + resolvedDependencies.moduleDescriptors.resolvedDescriptors + resolvedDependencies.moduleDescriptors.forwardDeclarationsModule module.setDependencies(dependencies, resolvedDependencies.friends) } else { assert (resolvedDependencies.moduleDescriptors.resolvedDescriptors.isEmpty()) moduleContext.setDependencies(module) + // [K][Suspend]FunctionN belong to stdlib. + additionalPackages += functionInterfacePackageFragmentProvider(projectContext.storageManager, module) } - return analyzeFilesWithGivenTrace(files, BindingTraceContext(), moduleContext, context) + return analyzeFilesWithGivenTrace(files, BindingTraceContext(), moduleContext, context, additionalPackages) } fun analyzeFilesWithGivenTrace( files: Collection, trace: BindingTrace, moduleContext: ModuleContext, - context: Context + context: Context, + additionalPackages: List = emptyList() ): AnalysisResult { // we print out each file we compile if frontend phase is verbose @@ -73,7 +79,8 @@ internal object TopDownAnalyzerFacadeForKonan { val analyzerForKonan = createTopDownAnalyzerProviderForKonan( moduleContext, trace, FileBasedDeclarationProviderFactory(moduleContext.storageManager, files), - context.config.configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS)!! + context.config.configuration.get(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS)!!, + additionalPackages ) { initContainer(context.config) }.apply { diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt index d5343d85ee1..b5d1d415a83 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ToplevelPhases.kt @@ -10,13 +10,11 @@ import org.jetbrains.kotlin.backend.konan.ir.KonanSymbols import org.jetbrains.kotlin.backend.konan.llvm.* import org.jetbrains.kotlin.backend.konan.lower.ExpectToActualDefaultValueCopier import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExport -import org.jetbrains.kotlin.backend.konan.serialization.KonanDeclarationTable -import org.jetbrains.kotlin.backend.konan.serialization.KonanIrLinker -import org.jetbrains.kotlin.backend.konan.serialization.KonanIrModuleSerializer -import org.jetbrains.kotlin.backend.konan.serialization.KonanSerializationUtil +import org.jetbrains.kotlin.backend.konan.serialization.* import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport import org.jetbrains.kotlin.config.CommonConfigurationKeys import org.jetbrains.kotlin.config.languageVersionSettings +import org.jetbrains.kotlin.descriptors.konan.isKonanStdlib import org.jetbrains.kotlin.ir.declarations.IrFile import org.jetbrains.kotlin.ir.declarations.IrModuleFragment import org.jetbrains.kotlin.ir.util.SymbolTable @@ -159,12 +157,19 @@ internal val psiToIrPhase = konanUnitPhase( dependenciesCount = dependencies.size } - val symbols = KonanSymbols(this, symbolTable, symbolTable.lazyWrapper) - val module = translator.generateModuleFragment(generatorContext, environment.getSourceFiles(), deserializer) + val functionIrClassFactory = BuiltInFictitiousFunctionIrClassFactory( + symbolTable, generatorContext.irBuiltIns, reflectionTypes) + val symbols = KonanSymbols(this, symbolTable, symbolTable.lazyWrapper, functionIrClassFactory) + val module = translator.generateModuleFragment(generatorContext, environment.getSourceFiles(), + deserializer, listOf(functionIrClassFactory)) irModule = module irModules = deserializer.modules ir.symbols = symbols + + functionIrClassFactory.module = + (listOf(irModule!!) + irModules.values) + .single { it.descriptor.isKonanStdlib() } }, name = "Psi2Ir", description = "Psi to IR conversion", @@ -174,6 +179,7 @@ internal val psiToIrPhase = konanUnitPhase( internal val destroySymbolTablePhase = konanUnitPhase( op = { this.symbolTable = null // TODO: invalidate symbolTable itself. + ir.symbols.functionIrClassFactory.symbolTable = null }, name = "DestroySymbolTable", description = "Destroy SymbolTable", diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt index e4f7d58c032..3a9a1bfd8b4 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/cgen/CBridgeGen.kt @@ -710,7 +710,7 @@ private fun KotlinStubs.mapBlockType( location: TypeLocation ): ObjCBlockPointerValuePassing { type as IrSimpleType - require(type.classifier == symbols.functions[type.arguments.size - 1]) + require(type.classifier == symbols.functionN(type.arguments.size - 1)) val returnTypeArgument = type.arguments.last() val valueReturning = when (returnTypeArgument) { is IrTypeProjection -> if (returnTypeArgument.variance == Variance.INVARIANT) { diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/injection.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/injection.kt index 07cb9c25e3f..150c20dfbd7 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/injection.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/injection.kt @@ -7,6 +7,8 @@ package org.jetbrains.kotlin.backend.konan import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.container.* import org.jetbrains.kotlin.context.ModuleContext +import org.jetbrains.kotlin.descriptors.PackageFragmentProvider +import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.frontend.di.configureModule import org.jetbrains.kotlin.platform.konan.KonanPlatforms @@ -22,6 +24,7 @@ fun createTopDownAnalyzerProviderForKonan( bindingTrace: BindingTrace, declarationProviderFactory: DeclarationProviderFactory, languageVersionSettings: LanguageVersionSettings, + additionalPackages: List, initContainer: StorageComponentContainer.() -> Unit ): ComponentProvider { return createContainer("TopDownAnalyzerForKonan", NativePlatformAnalyzerServices) { @@ -37,6 +40,9 @@ fun createTopDownAnalyzerProviderForKonan( initContainer() }.apply { - get().initialize(get().packageFragmentProvider) + val packagePartProviders = mutableListOf(get().packageFragmentProvider) + val moduleDescriptor = get() + packagePartProviders += additionalPackages + moduleDescriptor.initialize(CompositePackageFragmentProvider(packagePartProviders)) } } diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt index 4f92ce2ed25..eae92289b43 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/ir/Ir.kt @@ -40,7 +40,12 @@ internal class KonanIr(context: Context, irModule: IrModuleFragment): Ir(context, lazySymbolTable) { +internal class KonanSymbols( + context: Context, + private val symbolTable: SymbolTable, + lazySymbolTable: ReferenceSymbolTable, + val functionIrClassFactory: BuiltInFictitiousFunctionIrClassFactory +): Symbols(context, lazySymbolTable) { val entryPoint = findMainEntryPoint(context)?.let { symbolTable.referenceSimpleFunction(it) } @@ -481,23 +486,16 @@ internal class KonanSymbols(context: Context, private val symbolTable: SymbolTab .getContributedClassifier(Name.identifier(name), NoLookupLocation.FROM_BACKEND) as ClassDescriptor ) - val functions = (0 .. KONAN_FUNCTION_INTERFACES_MAX_PARAMETERS) - .map { symbolTable.referenceClass(builtIns.getFunction(it)) } + override fun functionN(n: Int) = functionIrClassFactory.function(n).symbol - val kFunctions = (0 .. KONAN_FUNCTION_INTERFACES_MAX_PARAMETERS) - .map { symbolTable.referenceClass(context.reflectionTypes.getKFunction(it)) } + override fun suspendFunctionN(n: Int) = functionIrClassFactory.suspendFunction(n).symbol - // Since KSuspendFunctionN inherits Function{N+1} and we only have 0..22 range, skip the last one for now. - val kSuspendFunctions = (0 .. KONAN_FUNCTION_INTERFACES_MAX_PARAMETERS - 1) - .map { symbolTable.referenceClass(context.reflectionTypes.getKSuspendFunction(it)) } + fun kFunctionN(n: Int) = functionIrClassFactory.kFunction(n).symbol - fun getKFunctionType(returnType: IrType, parameterTypes: List): IrType { - val kFunctionClassSymbol = kFunctions[parameterTypes.size] - return kFunctionClassSymbol.typeWith(parameterTypes + returnType) - } + fun kSuspendFunctionN(n: Int) = functionIrClassFactory.kSuspendFunction(n).symbol - val suspendFunctions = (0 .. KONAN_FUNCTION_INTERFACES_MAX_PARAMETERS) - .map { symbolTable.referenceClass(builtIns.getSuspendFunction(it)) } + fun getKFunctionType(returnType: IrType, parameterTypes: List) = + kFunctionN(parameterTypes.size).typeWith(parameterTypes + returnType) val baseClassSuite = getKonanTestClass("BaseClassSuite") val topLevelSuite = getKonanTestClass("TopLevelSuite") diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/BlockPointerSupport.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/BlockPointerSupport.kt index 8c49f55cff8..f6637f0eebd 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/BlockPointerSupport.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/BlockPointerSupport.kt @@ -6,6 +6,7 @@ package org.jetbrains.kotlin.backend.konan.llvm.objcexport import llvm.* +import org.jetbrains.kotlin.backend.common.ir.simpleFunctions import org.jetbrains.kotlin.backend.konan.llvm.* import org.jetbrains.kotlin.backend.konan.objcexport.BlockPointerBridge import org.jetbrains.kotlin.descriptors.konan.CurrentKonanModuleOrigin @@ -15,7 +16,7 @@ import org.jetbrains.kotlin.util.OperatorNameConventions internal fun ObjCExportCodeGenerator.generateBlockToKotlinFunctionConverter( bridge: BlockPointerBridge ): LLVMValueRef { - val irInterface = symbols.functions[bridge.numberOfParameters].owner + val irInterface = symbols.functionN(bridge.numberOfParameters).owner val invokeMethod = irInterface.declarations.filterIsInstance() .single { it.name == OperatorNameConventions.INVOKE } @@ -231,8 +232,8 @@ internal class BlockAdapterToFunctionGenerator(val objCExportCodeGenerator: ObjC objCReferenceToKotlin(param(index), Lifetime.ARGUMENT) } - val invokeMethod = context.ir.symbols.functions[numberOfParameters].owner.declarations - .filterIsInstance().single { it.name == OperatorNameConventions.INVOKE } + val invokeMethod = context.ir.symbols.functionN(numberOfParameters).owner.simpleFunctions() + .single { it.name == OperatorNameConventions.INVOKE } val callee = lookupVirtualImpl(kotlinFunction, invokeMethod) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt index e16d281ad0d..504ef835464 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt @@ -461,15 +461,15 @@ private fun ObjCExportCodeGenerator.emitBoxConverter( } private fun ObjCExportCodeGenerator.emitFunctionConverters() { - (0 .. ObjCExportMapper.maxFunctionTypeParameterCount).forEach { numberOfParameters -> - val converter = kotlinFunctionToBlockConverter(BlockPointerBridge(numberOfParameters, returnsVoid = false)) - setObjCExportTypeInfo(symbols.functions[numberOfParameters].owner, constPointer(converter)) + context.ir.symbols.functionIrClassFactory.builtFunctionNClasses.forEach { functionClass -> + val converter = kotlinFunctionToBlockConverter(BlockPointerBridge(functionClass.arity, returnsVoid = false)) + setObjCExportTypeInfo(functionClass.irClass, constPointer(converter)) } } private fun ObjCExportCodeGenerator.emitBlockToKotlinFunctionConverters() { - val converters = (0 .. ObjCExportMapper.maxFunctionTypeParameterCount).map { - val bridge = BlockPointerBridge(numberOfParameters = it, returnsVoid = false) + val converters = context.ir.symbols.functionIrClassFactory.builtFunctionNClasses.map { + val bridge = BlockPointerBridge(numberOfParameters = it.arity, returnsVoid = false) constPointer(blockToKotlinFunctionConverter(bridge)) } val ptr = staticData.placeGlobalArray( diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt index 9aa7e345744..106f34f89a3 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/lower/CallableReferenceLowering.kt @@ -201,10 +201,10 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass val suspendFunctionClass: IrClass? if (isKSuspendFunction) { superTypes += kSuspendFunctionImplSymbol.typeWith(referencedFunction.returnType) - functionClass = symbols.functions[numberOfParameters + 1].owner + functionClass = symbols.functionN(numberOfParameters + 1).owner val continuationType = continuationClassSymbol.typeWith(referencedFunction.returnType) superTypes += functionClass.typeWith(functionParameterTypes + continuationType + irBuiltIns.anyNType) - suspendFunctionClass = symbols.kSuspendFunctions[numberOfParameters].owner + suspendFunctionClass = symbols.kSuspendFunctionN(numberOfParameters).owner superTypes += suspendFunctionClass.typeWith(functionParameterTypes + referencedFunction.returnType) } else { @@ -212,7 +212,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass kFunctionImplSymbol.typeWith(referencedFunction.returnType) else irBuiltIns.anyType - functionClass = (if (isKFunction) symbols.kFunctions else symbols.functions)[numberOfParameters].owner + functionClass = (if (isKFunction) symbols.kFunctionN(numberOfParameters) else symbols.functionN(numberOfParameters)).owner superTypes += functionClass.typeWith(functionParameterTypes + referencedFunction.returnType) val lastParameterType = unboundFunctionParameters.lastOrNull()?.type if (lastParameterType?.classifierOrNull != continuationClassSymbol) @@ -220,7 +220,7 @@ internal class CallableReferenceLowering(val context: Context): FileLoweringPass else { lastParameterType as IrSimpleType // If the last parameter is Continuation<> inherit from SuspendFunction. - suspendFunctionClass = symbols.suspendFunctions[numberOfParameters - 1].owner + suspendFunctionClass = symbols.suspendFunctionN(numberOfParameters - 1).owner val suspendFunctionClassTypeParameters = functionParameterTypes.dropLast(1) + (lastParameterType.arguments.single().typeOrNull ?: irBuiltIns.anyNType) superTypes += suspendFunctionClass.symbol.typeWith(suspendFunctionClassTypeParameters) diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt index f753f41d0ae..5b53f811710 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt @@ -27,10 +27,6 @@ internal class ObjCExportMapper( internal val deprecationResolver: DeprecationResolver? = null, private val local: Boolean = false ) { - companion object { - val maxFunctionTypeParameterCount get() = KONAN_FUNCTION_INTERFACES_MAX_PARAMETERS - } - fun getCustomTypeMapper(descriptor: ClassDescriptor): CustomTypeMapper? = CustomTypeMappers.getMapper(descriptor) val hiddenTypes: Set get() = CustomTypeMappers.hiddenTypes diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/DFGBuilder.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/DFGBuilder.kt index 36dc863f1c9..d91924dccef 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/DFGBuilder.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/optimizations/DFGBuilder.kt @@ -17,7 +17,6 @@ import org.jetbrains.kotlin.backend.konan.descriptors.target import org.jetbrains.kotlin.backend.konan.ir.* import org.jetbrains.kotlin.backend.konan.llvm.functionName import org.jetbrains.kotlin.backend.konan.llvm.localHash -import org.jetbrains.kotlin.backend.konan.llvm.longName import org.jetbrains.kotlin.ir.IrElement import org.jetbrains.kotlin.ir.declarations.* import org.jetbrains.kotlin.ir.expressions.* @@ -410,8 +409,8 @@ internal class ModuleDFGBuilder(val context: Context, val irModule: IrModuleFrag private val createUninitializedInstanceSymbol = symbols.createUninitializedInstance private val initInstanceSymbol = symbols.initInstance private val executeImplSymbol = symbols.executeImpl - private val executeImplProducerClassSymbol = symbols.functions[0] - private val executeImplProducerInvoke = executeImplProducerClassSymbol.owner.simpleFunctions() + private val executeImplProducerClass = symbols.functionN(0).owner + private val executeImplProducerInvoke = executeImplProducerClass.simpleFunctions() .single { it.name == OperatorNameConventions.INVOKE } private val reinterpret = symbols.reinterpret diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanDeserializeDescriptorReference.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanDeserializeDescriptorReference.kt index e4deb704e88..4c7721dd002 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanDeserializeDescriptorReference.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanDeserializeDescriptorReference.kt @@ -1,30 +1,13 @@ package org.jetbrains.kotlin.backend.konan.serialization -import org.jetbrains.kotlin.backend.common.serialization.DescriptorReferenceDeserializer -import org.jetbrains.kotlin.backend.common.serialization.DescriptorUniqIdAware -import org.jetbrains.kotlin.backend.common.serialization.UniqId -import org.jetbrains.kotlin.backend.common.serialization.UniqIdKey +import org.jetbrains.kotlin.backend.common.serialization.* import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.incremental.components.NoLookupLocation -import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe -import org.jetbrains.kotlin.resolve.scopes.MemberScope -import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedClassDescriptor +import org.jetbrains.kotlin.ir.descriptors.IrBuiltIns -// This is all information needed to find a descriptor in the -// tree of deserialized descriptors. Think of it as base + offset. -// packageFqName + classFqName + index allow to localize some deserialized descriptor. -// Then the rest of the fields allow to find the needed descriptor relative to the one with index. class KonanDescriptorReferenceDeserializer( currentModule: ModuleDescriptor, - resolvedForwardDeclarations: MutableMap) - : DescriptorReferenceDeserializer(currentModule, resolvedForwardDeclarations), - DescriptorUniqIdAware by KonanDescriptorUniqIdAware{ - - // TODO: these are dummies. Eliminate them. - override fun resolveSpecialDescriptor(fqn: FqName): DeclarationDescriptor = currentModule - override fun checkIfSpecialDescriptorId(id: Long): Boolean = false - override fun getDescriptorIdOrNull(descriptor: DeclarationDescriptor): Long? = null -} + mangler: KotlinMangler, + builtIns: IrBuiltIns, + resolvedForwardDeclarations: MutableMap +): DescriptorReferenceDeserializer(currentModule, mangler, builtIns, resolvedForwardDeclarations), + DescriptorUniqIdAware by KonanDescriptorUniqIdAware diff --git a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt index 1a507e9dc23..d8f49b77c88 100644 --- a/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt +++ b/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/serialization/KonanIrlinker.kt @@ -17,10 +17,7 @@ package org.jetbrains.kotlin.backend.konan.serialization import org.jetbrains.kotlin.backend.common.LoggingContext -import org.jetbrains.kotlin.backend.common.serialization.DescriptorUniqIdAware -import org.jetbrains.kotlin.backend.common.serialization.KotlinIrLinker -import org.jetbrains.kotlin.backend.common.serialization.UniqId -import org.jetbrains.kotlin.backend.common.serialization.UniqIdKey +import org.jetbrains.kotlin.backend.common.serialization.* import org.jetbrains.kotlin.backend.konan.descriptors.konanLibrary import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.ir.declarations.IrFile @@ -39,7 +36,7 @@ class KonanIrLinker( DescriptorUniqIdAware by KonanDescriptorUniqIdAware { override val descriptorReferenceDeserializer = - KonanDescriptorReferenceDeserializer(currentModule, resolvedForwardDeclarations) + KonanDescriptorReferenceDeserializer(currentModule, KonanDeclarationTable(builtIns, DescriptorTable()), builtIns, resolvedForwardDeclarations) override fun reader(moduleDescriptor: ModuleDescriptor, uniqId: UniqId) = moduleDescriptor.konanLibrary!!.irDeclaration(uniqId.index, uniqId.isLocal) diff --git a/extracted/konan.serializer/src/org/jetbrains/kotlin/serialization/konan/impl/KonanDeserializedModuleDescriptorFactoryImpl.kt b/extracted/konan.serializer/src/org/jetbrains/kotlin/serialization/konan/impl/KonanDeserializedModuleDescriptorFactoryImpl.kt index 76265f298c2..18cdfd8c596 100644 --- a/extracted/konan.serializer/src/org/jetbrains/kotlin/serialization/konan/impl/KonanDeserializedModuleDescriptorFactoryImpl.kt +++ b/extracted/konan.serializer/src/org/jetbrains/kotlin/serialization/konan/impl/KonanDeserializedModuleDescriptorFactoryImpl.kt @@ -1,18 +1,20 @@ package org.jetbrains.kotlin.serialization.konan.impl import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.builtins.functions.functionInterfacePackageFragmentProvider import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.contracts.ContractDeserializerImpl import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.NotFoundClasses import org.jetbrains.kotlin.descriptors.PackageFragmentProvider import org.jetbrains.kotlin.descriptors.PackageFragmentProviderImpl +import org.jetbrains.kotlin.descriptors.impl.CompositePackageFragmentProvider import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.descriptors.konan.DeserializedKonanModuleOrigin import org.jetbrains.kotlin.descriptors.konan.KonanModuleDescriptorFactory +import org.jetbrains.kotlin.descriptors.konan.isKonanStdlib import org.jetbrains.kotlin.incremental.components.LookupTracker import org.jetbrains.kotlin.konan.library.KonanLibrary -import org.jetbrains.kotlin.konan.library.impl.KonanLibraryImpl import org.jetbrains.kotlin.konan.library.resolver.PackageAccessedHandler import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.CompilerDeserializationConfiguration @@ -68,7 +70,14 @@ internal class KonanDeserializedModuleDescriptorFactoryImpl( moduleDescriptor, deserializationConfiguration) - moduleDescriptor.initialize(provider) + if (!moduleDescriptor.isKonanStdlib()) + moduleDescriptor.initialize(provider) + else { + // [K][Suspend]FunctionN belong to stdlib. + val packagePartProviders = mutableListOf(provider) + packagePartProviders += functionInterfacePackageFragmentProvider(storageManager, moduleDescriptor) + moduleDescriptor.initialize(CompositePackageFragmentProvider(packagePartProviders)) + } return moduleDescriptor } diff --git a/runtime/src/main/kotlin/kotlin/Functions.kt b/runtime/src/main/kotlin/kotlin/Functions.kt deleted file mode 100644 index ab7c5cbb2ea..00000000000 --- a/runtime/src/main/kotlin/kotlin/Functions.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -package kotlin - -public interface Function0 : Function { - operator fun invoke(): R -} - -public interface Function1 : Function { - operator fun invoke(p1: P1): R -} - -public interface Function2 : Function { - operator fun invoke(p1: P1, p2: P2): R -} - -public interface Function3 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3): R -} - -public interface Function4 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R -} - -public interface Function5 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R -} - -public interface Function6 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R -} - -public interface Function7 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R -} - -public interface Function8 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R -} - -public interface Function9 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R -} - -public interface Function10 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R -} - -public interface Function11 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R -} - -public interface Function12 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R -} - -public interface Function13 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R -} - -public interface Function14 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R -} - -public interface Function15 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R -} - -public interface Function16 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R -} - -public interface Function17 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R -} - -public interface Function18 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R -} - -public interface Function19 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R -} - -public interface Function20 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R -} - -public interface Function21 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R -} - -public interface Function22 : Function { - operator fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R -} diff --git a/runtime/src/main/kotlin/kotlin/coroutines/SuspendFunctions.kt b/runtime/src/main/kotlin/kotlin/coroutines/SuspendFunctions.kt deleted file mode 100644 index 0459a932860..00000000000 --- a/runtime/src/main/kotlin/kotlin/coroutines/SuspendFunctions.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -package kotlin.coroutines - -public interface SuspendFunction0 : SuspendFunction { - operator suspend fun invoke(): R -} - -public interface SuspendFunction1 : SuspendFunction { - operator suspend fun invoke(p1: P1): R -} - -public interface SuspendFunction2 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2): R -} - -public interface SuspendFunction3 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3): R -} - -public interface SuspendFunction4 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4): R -} - -public interface SuspendFunction5 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5): R -} - -public interface SuspendFunction6 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6): R -} - -public interface SuspendFunction7 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7): R -} - -public interface SuspendFunction8 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8): R -} - -public interface SuspendFunction9 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9): R -} - -public interface SuspendFunction10 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10): R -} - -public interface SuspendFunction11 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11): R -} - -public interface SuspendFunction12 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12): R -} - -public interface SuspendFunction13 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13): R -} - -public interface SuspendFunction14 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14): R -} - -public interface SuspendFunction15 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15): R -} - -public interface SuspendFunction16 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16): R -} - -public interface SuspendFunction17 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17): R -} - -public interface SuspendFunction18 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18): R -} - -public interface SuspendFunction19 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19): R -} - -public interface SuspendFunction20 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20): R -} - -public interface SuspendFunction21 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21): R -} - -public interface SuspendFunction22 : SuspendFunction { - operator suspend fun invoke(p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7, p8: P8, p9: P9, p10: P10, p11: P11, p12: P12, p13: P13, p14: P14, p15: P15, p16: P16, p17: P17, p18: P18, p19: P19, p20: P20, p21: P21, p22: P22): R -} diff --git a/runtime/src/main/kotlin/kotlin/reflect/KFunctions.kt b/runtime/src/main/kotlin/kotlin/reflect/KFunctions.kt deleted file mode 100644 index df42c7d2df5..00000000000 --- a/runtime/src/main/kotlin/kotlin/reflect/KFunctions.kt +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -package kotlin.reflect - -// (0..22).joinToString("\n") { i -> "interface KFunction$i<${(1..i).joinToString("") { j -> "in P$j, " }}out R> : Function$i<${(1..i).joinToString("") { j -> "P$j, " }}R>, KFunction\n" } - -interface KFunction0 : Function0, KFunction - -interface KFunction1 : Function1, KFunction - -interface KFunction2 : Function2, KFunction - -interface KFunction3 : Function3, KFunction - -interface KFunction4 : Function4, KFunction - -interface KFunction5 : Function5, KFunction - -interface KFunction6 : Function6, KFunction - -interface KFunction7 : Function7, KFunction - -interface KFunction8 : Function8, KFunction - -interface KFunction9 : Function9, KFunction - -interface KFunction10 : Function10, KFunction - -interface KFunction11 : Function11, KFunction - -interface KFunction12 : Function12, KFunction - -interface KFunction13 : Function13, KFunction - -interface KFunction14 : Function14, KFunction - -interface KFunction15 : Function15, KFunction - -interface KFunction16 : Function16, KFunction - -interface KFunction17 : Function17, KFunction - -interface KFunction18 : Function18, KFunction - -interface KFunction19 : Function19, KFunction - -interface KFunction20 : Function20, KFunction - -interface KFunction21 : Function21, KFunction - -interface KFunction22 : Function22, KFunction - diff --git a/runtime/src/main/kotlin/kotlin/reflect/KSuspendFunctions.kt b/runtime/src/main/kotlin/kotlin/reflect/KSuspendFunctions.kt deleted file mode 100644 index aee829d080a..00000000000 --- a/runtime/src/main/kotlin/kotlin/reflect/KSuspendFunctions.kt +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2010-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license - * that can be found in the LICENSE file. - */ - -@file:Suppress("SUPERTYPE_IS_SUSPEND_FUNCTION_TYPE") - -package kotlin.reflect - -import kotlin.coroutines.* - -// (0..22).joinToString("\n") { i -> "interface KSuspendFunction$i<${(1..i).joinToString("") { j -> "in P$j, " }}out R> : SuspendFunction$i<${(1..i).joinToString("") { j -> "P$j, " }}R>, KFunction\n" } - -interface KSuspendFunction0 : SuspendFunction0, KFunction - -interface KSuspendFunction1 : SuspendFunction1, KFunction - -interface KSuspendFunction2 : SuspendFunction2, KFunction - -interface KSuspendFunction3 : SuspendFunction3, KFunction - -interface KSuspendFunction4 : SuspendFunction4, KFunction - -interface KSuspendFunction5 : SuspendFunction5, KFunction - -interface KSuspendFunction6 : SuspendFunction6, KFunction - -interface KSuspendFunction7 : SuspendFunction7, KFunction - -interface KSuspendFunction8 : SuspendFunction8, KFunction - -interface KSuspendFunction9 : SuspendFunction9, KFunction - -interface KSuspendFunction10 : SuspendFunction10, KFunction - -interface KSuspendFunction11 : SuspendFunction11, KFunction - -interface KSuspendFunction12 : SuspendFunction12, KFunction - -interface KSuspendFunction13 : SuspendFunction13, KFunction - -interface KSuspendFunction14 : SuspendFunction14, KFunction - -interface KSuspendFunction15 : SuspendFunction15, KFunction - -interface KSuspendFunction16 : SuspendFunction16, KFunction - -interface KSuspendFunction17 : SuspendFunction17, KFunction - -interface KSuspendFunction18 : SuspendFunction18, KFunction - -interface KSuspendFunction19 : SuspendFunction19, KFunction - -interface KSuspendFunction20 : SuspendFunction20, KFunction - -interface KSuspendFunction21 : SuspendFunction21, KFunction - -// Comment for now. The reason: https://github.com/JetBrains/kotlin/blob/ad1b795a69925e6ee8c79cbbd05cce8cd27a6704/compiler/serialization/src/org/jetbrains/kotlin/serialization/DescriptorSerializer.kt#L555 -//interface KSuspendFunction22 : SuspendFunction22, KFunction