diff --git a/build.gradle.kts b/build.gradle.kts index 6ca052bf111..5e7a518629a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -344,7 +344,11 @@ val projectsUsedInIntelliJKotlinPlugin = ":kotlin-gradle-statistics", ":jps:jps-common", ) + - if (kotlinBuildProperties.isKotlinNativeEnabled) arrayOf(":kotlin-native:backend.native") else emptyArray() + arrayOf( + ":native:base", + ":native:objcexport-header-generator", + ":compiler:ir.serialization.native" + ) extra["projectsUsedInIntelliJKotlinPlugin"] = projectsUsedInIntelliJKotlinPlugin @@ -415,7 +419,7 @@ extra["compilerArtifactsForIde"] = listOfNotNull( ":prepare:ide-plugin-dependencies:assignment-compiler-plugin-for-ide", ":prepare:ide-plugin-dependencies:parcelize-compiler-plugin-for-ide", ":prepare:ide-plugin-dependencies:lombok-compiler-plugin-for-ide", - ":prepare:ide-plugin-dependencies:kotlin-backend-native-for-ide".takeIf { kotlinBuildProperties.isKotlinNativeEnabled }, + ":prepare:ide-plugin-dependencies:kotlin-objcexport-header-generator-for-ide", ":prepare:ide-plugin-dependencies:kotlin-compiler-tests-for-ide", ":prepare:ide-plugin-dependencies:kotlin-compiler-testdata-for-ide", ":prepare:ide-plugin-dependencies:low-level-api-fir-for-ide", diff --git a/kotlin-native/backend.native/build.gradle b/kotlin-native/backend.native/build.gradle index c879f24c87c..2b40a071252 100644 --- a/kotlin-native/backend.native/build.gradle +++ b/kotlin-native/backend.native/build.gradle @@ -29,12 +29,6 @@ sourceSets { cli_bc { kotlin.srcDir 'cli.bc/src' } - - test { - kotlin { - srcDir 'functionalTest/src' - } - } } compileCompilerKotlin { @@ -43,6 +37,7 @@ compileCompilerKotlin { '-opt-in=kotlin.RequiresOptIn', "-opt-in=kotlinx.cinterop.BetaInteropApi", "-opt-in=kotlinx.cinterop.ExperimentalForeignApi", + "-opt-in=org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi", '-Xskip-prerelease-check'] } @@ -159,6 +154,8 @@ dependencies { kotlin_script_runtime_jar project(":kotlin-script-runtime") compilerApi project(":kotlin-native:utilities:basic-utils") + compilerApi project(":native:objcexport-header-generator") + compilerApi project(":native:base") compilerImplementation project(":kotlin-compiler") compilerApi project(":native:kotlin-native-utils") @@ -187,11 +184,6 @@ dependencies { cli_bcApi sourceSets.compiler.output cli_bcApiElements sourceSets.cli_bc.output - - testImplementation(project(path: ":compiler:tests-common", configuration: "tests-jar")) - testImplementation(libs.junit.jupiter.api) - testImplementation(libs.junit.jupiter.params) - testRuntimeOnly(libs.junit.jupiter.engine) } classes.dependsOn 'compilerClasses', 'cli_bcClasses' @@ -251,27 +243,4 @@ RepoArtifacts.sourcesJar(project) { it.from(sourceSets["compiler"].allSource) } -RepoArtifacts.javadocJar(project) - -/* -Configure 'test' task - */ - -TasksKt.projectTest(project, JUnitMode.JUnit5) -tasks { - test { - useJUnitPlatform() - dependsOn ':kotlin-native:dist' - systemProperty("org.jetbrains.kotlin.native.home", distDir.canonicalPath) - workingDir(rootProject.projectDir) - } -} - -kotlin { - target { - compilations { - test.associateWith(compiler) - } - } -} - +RepoArtifacts.javadocJar(project) \ No newline at end of file diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/IrTypeInlineClassesSupport.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/IrTypeInlineClassesSupport.kt new file mode 100644 index 00000000000..ea417c7ec1f --- /dev/null +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/IrTypeInlineClassesSupport.kt @@ -0,0 +1,93 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.konan + +import org.jetbrains.kotlin.backend.konan.ir.getSuperClassNotAny +import org.jetbrains.kotlin.ir.declarations.IrClass +import org.jetbrains.kotlin.ir.declarations.IrProperty +import org.jetbrains.kotlin.ir.declarations.inlineClassRepresentation +import org.jetbrains.kotlin.ir.declarations.isSingleFieldValueClass +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol +import org.jetbrains.kotlin.ir.symbols.IrScriptSymbol +import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.types.classifierOrFail +import org.jetbrains.kotlin.ir.types.isNullable +import org.jetbrains.kotlin.ir.types.makeNullable +import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.utils.atMostOne + +fun IrType.getInlinedClassNative(): IrClass? = IrTypeInlineClassesSupport.getInlinedClass(this) + +fun IrType.isInlinedNative(): Boolean = IrTypeInlineClassesSupport.isInlined(this) + +fun IrClass.isInlined(): Boolean = IrTypeInlineClassesSupport.isInlined(this) + +fun IrClass.isNativePrimitiveType() = IrTypeInlineClassesSupport.isTopLevelClass(this) && + KonanPrimitiveType.byFqNameParts[packageFqName]?.get(name) != null + +fun IrType.computePrimitiveBinaryTypeOrNull(): PrimitiveBinaryType? = + this.computeBinaryType().primitiveBinaryTypeOrNull() + +fun IrType.computeBinaryType(): BinaryType = IrTypeInlineClassesSupport.computeBinaryType(this) + +fun IrClass.inlinedClassIsNullable(): Boolean = this.defaultType.makeNullable().getInlinedClassNative() == this // TODO: optimize + +fun IrClass.isUsedAsBoxClass(): Boolean = IrTypeInlineClassesSupport.isUsedAsBoxClass(this) + +fun IrType.binaryTypeIsReference(): Boolean = this.computePrimitiveBinaryTypeOrNull() == null + +internal inline fun IrType.unwrapToPrimitiveOrReference( + eachInlinedClass: (inlinedClass: IrClass, nullable: Boolean) -> Unit, + ifPrimitive: (primitiveType: KonanPrimitiveType, nullable: Boolean) -> R, + ifReference: (type: IrType) -> R +): R = IrTypeInlineClassesSupport.unwrapToPrimitiveOrReference(this, eachInlinedClass, ifPrimitive, ifReference) + +internal object IrTypeInlineClassesSupport : InlineClassesSupport() { + + override fun isNullable(type: IrType): Boolean = type.isNullable() + + override fun makeNullable(type: IrType): IrType = type.makeNullable() + + override tailrec fun erase(type: IrType): IrClass { + val classifier = type.classifierOrFail + return when (classifier) { + is IrClassSymbol -> classifier.owner + is IrTypeParameterSymbol -> erase(classifier.owner.superTypes.first()) + else -> error(classifier) + } + } + + override fun computeFullErasure(type: IrType): Sequence = when (val classifier = type.classifierOrFail) { + is IrClassSymbol -> sequenceOf(classifier.owner) + is IrTypeParameterSymbol -> classifier.owner.superTypes.asSequence().flatMap { computeFullErasure(it) } + is IrScriptSymbol -> classifier.unexpectedSymbolKind() + } + + override fun hasInlineModifier(clazz: IrClass): Boolean = clazz.isSingleFieldValueClass + + override fun getNativePointedSuperclass(clazz: IrClass): IrClass? { + var superClass: IrClass? = clazz + while (superClass != null && InteropFqNames.nativePointed.toSafe() != superClass.fqNameWhenAvailable) + superClass = superClass.getSuperClassNotAny() + return superClass + } + + override fun getInlinedClassUnderlyingType(clazz: IrClass): IrType = + clazz.constructors.firstOrNull { it.isPrimary }?.valueParameters?.single()?.type + ?: clazz.declarations.filterIsInstance().atMostOne { it.backingField?.takeUnless { it.isStatic } != null }?.backingField?.type + ?: clazz.inlineClassRepresentation!!.underlyingType + + override fun getPackageFqName(clazz: IrClass) = + clazz.packageFqName + + override fun getName(clazz: IrClass): Name? = + clazz.name + + override fun isTopLevelClass(clazz: IrClass): Boolean = clazz.isTopLevel +} \ No newline at end of file diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/DescriptorUtils.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/DescriptorUtils.kt index 8d35eb3fca4..3ef7ff2ae25 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/DescriptorUtils.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/descriptors/DescriptorUtils.kt @@ -41,31 +41,6 @@ internal val IrFunction.isTypedIntrinsic: Boolean internal val IrConstructor.isConstantConstructorIntrinsic: Boolean get() = annotations.hasAnnotation(KonanFqNames.constantConstructorIntrinsic) -internal val arrayTypes = setOf( - "kotlin.Array", - "kotlin.ByteArray", - "kotlin.CharArray", - "kotlin.ShortArray", - "kotlin.IntArray", - "kotlin.LongArray", - "kotlin.FloatArray", - "kotlin.DoubleArray", - "kotlin.BooleanArray", - "kotlin.native.ImmutableBlob", - "kotlin.native.internal.NativePtrArray" -) - -internal val arraysWithFixedSizeItems = setOf( - "kotlin.ByteArray", - "kotlin.CharArray", - "kotlin.ShortArray", - "kotlin.IntArray", - "kotlin.LongArray", - "kotlin.FloatArray", - "kotlin.DoubleArray", - "kotlin.BooleanArray" -) - internal val IrClass.isArray: Boolean get() = this.fqNameForIrSerialization.asString() in arrayTypes diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt index 471f314b99e..7de3405365c 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCExportCodeGenerator.kt @@ -1075,10 +1075,10 @@ private fun ObjCExportCodeGenerator.generateObjCImp( is MethodBridge.ReturnValue.Mapped -> if (LLVMTypeOf(targetResult!!) == llvm.voidType) { returnBridge.bridge.makeNothing(llvm) } else { - when (returnBridge.bridge) { + when (val bridge = returnBridge.bridge) { is ReferenceBridge -> return autoreleaseAndRet(kotlinReferenceToRetainedObjC(targetResult)) - is BlockPointerBridge -> return autoreleaseAndRet(kotlinFunctionToRetainedObjCBlockPointer(returnBridge.bridge, targetResult)) - is ValueTypeBridge -> kotlinToObjC(targetResult, returnBridge.bridge.objCValueType) + is BlockPointerBridge -> return autoreleaseAndRet(kotlinFunctionToRetainedObjCBlockPointer(bridge, targetResult)) + is ValueTypeBridge -> kotlinToObjC(targetResult, bridge.objCValueType) } } MethodBridge.ReturnValue.WithError.Success -> llvm.int8(1) // true @@ -1198,11 +1198,11 @@ private fun ObjCExportCodeGenerator.generateKotlinToObjCBridge( if (LLVMTypeOf(kotlinValue) == llvm.voidType) { bridge.bridge.makeNothing(llvm) } else { - when (bridge.bridge) { + when (val typeBridge = bridge.bridge) { is ReferenceBridge -> kotlinReferenceToRetainedObjC(kotlinValue).also { objCReferenceArgsToRelease += it } - is BlockPointerBridge -> kotlinFunctionToRetainedObjCBlockPointer(bridge.bridge, kotlinValue) // TODO: use stack-allocated block here. + is BlockPointerBridge -> kotlinFunctionToRetainedObjCBlockPointer(typeBridge, kotlinValue) // TODO: use stack-allocated block here. .also { objCReferenceArgsToRelease += it } - is ValueTypeBridge -> kotlinToObjC(kotlinValue, bridge.bridge.objCValueType) + is ValueTypeBridge -> kotlinToObjC(kotlinValue, typeBridge.objCValueType) } } } @@ -2006,3 +2006,26 @@ private fun NativeGenerationState.is64BitNSInteger(): Boolean { } return llvm.nsIntegerTypeWidth == 64L } + +private fun MethodBridge.parametersAssociated( + irFunction: IrFunction +): List> { + val kotlinParameters = irFunction.allParameters.iterator() + + return this.paramBridges.map { + when (it) { + is MethodBridgeValueParameter.Mapped, + MethodBridgeReceiver.Instance, + is MethodBridgeValueParameter.SuspendCompletion -> + it to kotlinParameters.next() + + MethodBridgeReceiver.Static, MethodBridgeSelector, MethodBridgeValueParameter.ErrorOutParameter -> + it to null + + MethodBridgeReceiver.Factory -> { + kotlinParameters.next() + it to null + } + } + }.also { assert(!kotlinParameters.hasNext()) } +} diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCValueTypeDefaultParameterAttributes.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCValueTypeDefaultParameterAttributes.kt new file mode 100644 index 00000000000..b5dd22deb95 --- /dev/null +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/llvm/objcexport/ObjCValueTypeDefaultParameterAttributes.kt @@ -0,0 +1,20 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.konan.llvm.objcexport + +import org.jetbrains.kotlin.backend.konan.llvm.LlvmParameterAttribute +import org.jetbrains.kotlin.backend.konan.objcexport.* + +internal val ObjCValueType.defaultParameterAttributes: List + get() = when (this) { + ObjCValueType.BOOL -> listOf(LlvmParameterAttribute.SignExt) + ObjCValueType.UNICHAR -> listOf(LlvmParameterAttribute.ZeroExt) + ObjCValueType.CHAR -> listOf(LlvmParameterAttribute.SignExt) + ObjCValueType.SHORT -> listOf(LlvmParameterAttribute.SignExt) + ObjCValueType.UNSIGNED_CHAR -> listOf(LlvmParameterAttribute.ZeroExt) + ObjCValueType.UNSIGNED_SHORT -> listOf(LlvmParameterAttribute.ZeroExt) + else -> emptyList() + } diff --git a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExport.kt b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExport.kt index 4356374ef31..fb70a107aab 100644 --- a/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExport.kt +++ b/kotlin-native/backend.native/compiler/ir/backend.native/src/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExport.kt @@ -11,14 +11,15 @@ import org.jetbrains.kotlin.backend.konan.driver.PhaseContext import org.jetbrains.kotlin.backend.konan.llvm.CodeGenerator import org.jetbrains.kotlin.backend.konan.llvm.objcexport.ObjCExportBlockCodeGenerator import org.jetbrains.kotlin.backend.konan.llvm.objcexport.ObjCExportCodeGenerator -import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.SourceFile +import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity +import org.jetbrains.kotlin.cli.common.messages.MessageUtil +import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.konan.exec.Command import org.jetbrains.kotlin.konan.file.File import org.jetbrains.kotlin.konan.file.createTempFile import org.jetbrains.kotlin.konan.target.CompilerOutputKind +import org.jetbrains.kotlin.renderer.DescriptorRenderer +import org.jetbrains.kotlin.resolve.source.getPsi internal class ObjCExportedInterface( val generatedClasses: Set, @@ -52,7 +53,7 @@ internal fun produceObjCExportInterface( val ignoreInterfaceMethodCollisions = config.configuration.getBoolean(BinaryOptions.objcExportIgnoreInterfaceMethodCollisions) val reportNameCollisions = config.configuration.getBoolean(BinaryOptions.objcExportReportNameCollisions) - val problemCollector = ObjCExportHeaderGeneratorImpl.ProblemCollector(context) + val problemCollector = ObjCExportCompilerProblemCollector(context) val namer = ObjCExportNamerImpl( moduleDescriptors.toSet(), @@ -66,11 +67,36 @@ internal fun produceObjCExportInterface( ignoreInterfaceMethodCollisions = ignoreInterfaceMethodCollisions, reportNameCollisions = reportNameCollisions, ) - val headerGenerator = ObjCExportHeaderGeneratorImpl(context, moduleDescriptors, mapper, namer, problemCollector, objcGenerics) + val shouldExportKDoc = context.shouldExportKDoc() + val additionalImports = context.config.configuration.getNotNull(KonanConfigKeys.FRAMEWORK_IMPORT_HEADERS) + val headerGenerator = ObjCExportHeaderGenerator.createInstance( + moduleDescriptors, mapper, namer, problemCollector, objcGenerics, shouldExportKDoc = shouldExportKDoc, + additionalImports = additionalImports) headerGenerator.translateModule() return headerGenerator.buildInterface() } +private class ObjCExportCompilerProblemCollector(val context: PhaseContext) : ObjCExportProblemCollector { + override fun reportWarning(text: String) { + context.reportCompilationWarning(text) + } + + override fun reportWarning(declaration: DeclarationDescriptor, text: String) { + val psi = (declaration as? DeclarationDescriptorWithSource)?.source?.getPsi() + ?: return reportWarning( + "$text\n (at ${DescriptorRenderer.COMPACT_WITH_SHORT_TYPES.render(declaration)})" + ) + + val location = MessageUtil.psiElementToMessageLocation(psi) + + context.messageCollector.report(CompilerMessageSeverity.WARNING, text, location) + } + + override fun reportException(throwable: Throwable) { + throw throwable + } +} + /** * Populate framework directory with headers, module and info.plist. */ @@ -189,3 +215,6 @@ private fun ObjCExportedInterface.generateWorkaroundForSwiftSR10177(generationSt // In this case resulting framework will likely be unusable due to compile errors when importing it. } } + +internal val PhaseContext.objCExportTopLevelNamePrefix: String + get() = abbreviate(config.fullExportedNamePrefix) diff --git a/kotlin-native/build.gradle b/kotlin-native/build.gradle index 2b5fafad4fd..15069f78892 100644 --- a/kotlin-native/build.gradle +++ b/kotlin-native/build.gradle @@ -165,6 +165,8 @@ dependencies { distPack project(':kotlin-native:Interop:StubGenerator') distPack project(':kotlin-native:Interop:Skia') distPack project(':kotlin-native:backend.native') + distPack project(':native:objcexport-header-generator') + distPack project(':native:base') distPack project(':kotlin-native:utilities:cli-runner') distPack project(':kotlin-native:utilities:basic-utils') distPack project(':kotlin-native:klib') diff --git a/native/base/build.gradle.kts b/native/base/build.gradle.kts new file mode 100644 index 00000000000..a6da10bddb2 --- /dev/null +++ b/native/base/build.gradle.kts @@ -0,0 +1,16 @@ +plugins { + kotlin("jvm") +} + +dependencies { + implementation(project(":compiler:cli-base")) + implementation(project(":compiler:cli-common")) + implementation(project(":core:compiler.common.native")) + implementation(project(":core:descriptors")) +} + +kotlin { + compilerOptions { + optIn.add("org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi") + } +} diff --git a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InlineClasses.kt b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InlineClasses.kt index 44e9601f43b..fc5bcb11aea 100644 --- a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InlineClasses.kt +++ b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InlineClasses.kt @@ -1,29 +1,14 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan -import org.jetbrains.kotlin.utils.atMostOne -import org.jetbrains.kotlin.descriptors.findPackage -import org.jetbrains.kotlin.backend.konan.ir.getSuperClassNotAny import org.jetbrains.kotlin.builtins.PrimitiveType import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.PackageFragmentDescriptor -import org.jetbrains.kotlin.ir.declarations.IrClass -import org.jetbrains.kotlin.ir.declarations.IrProperty -import org.jetbrains.kotlin.ir.declarations.inlineClassRepresentation -import org.jetbrains.kotlin.ir.declarations.isSingleFieldValueClass -import org.jetbrains.kotlin.ir.symbols.IrClassSymbol -import org.jetbrains.kotlin.ir.symbols.IrClassifierSymbol -import org.jetbrains.kotlin.ir.symbols.IrScriptSymbol -import org.jetbrains.kotlin.ir.symbols.IrTypeParameterSymbol -import org.jetbrains.kotlin.ir.types.IrType -import org.jetbrains.kotlin.ir.types.classifierOrFail -import org.jetbrains.kotlin.ir.types.isNullable -import org.jetbrains.kotlin.ir.types.makeNullable -import org.jetbrains.kotlin.ir.util.* +import org.jetbrains.kotlin.descriptors.findPackage import org.jetbrains.kotlin.name.ClassId import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.FqNameUnsafe @@ -35,12 +20,6 @@ import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.isNullable import org.jetbrains.kotlin.types.typeUtil.makeNullable -fun IrType.getInlinedClassNative(): IrClass? = IrTypeInlineClassesSupport.getInlinedClass(this) - -fun IrType.isInlinedNative(): Boolean = IrTypeInlineClassesSupport.isInlined(this) -fun IrClass.isInlined(): Boolean = IrTypeInlineClassesSupport.isInlined(this) -fun IrClass.isNativePrimitiveType() = IrTypeInlineClassesSupport.isTopLevelClass(this) && - KonanPrimitiveType.byFqNameParts[packageFqName]?.get(name) != null fun KotlinType.getInlinedClass(): ClassDescriptor? = KotlinTypeInlineClassesSupport.getInlinedClass(this) @@ -48,35 +27,22 @@ fun ClassDescriptor.isInlined(): Boolean = KotlinTypeInlineClassesSupport.isInli fun KotlinType.binaryRepresentationIsNullable() = KotlinTypeInlineClassesSupport.representationIsNullable(this) -internal inline fun KotlinType.unwrapToPrimitiveOrReference( +@InternalKotlinNativeApi +inline fun KotlinType.unwrapToPrimitiveOrReference( eachInlinedClass: (inlinedClass: ClassDescriptor, nullable: Boolean) -> Unit, ifPrimitive: (primitiveType: KonanPrimitiveType, nullable: Boolean) -> R, ifReference: (type: KotlinType) -> R ): R = KotlinTypeInlineClassesSupport.unwrapToPrimitiveOrReference(this, eachInlinedClass, ifPrimitive, ifReference) -internal inline fun IrType.unwrapToPrimitiveOrReference( - eachInlinedClass: (inlinedClass: IrClass, nullable: Boolean) -> Unit, - ifPrimitive: (primitiveType: KonanPrimitiveType, nullable: Boolean) -> R, - ifReference: (type: IrType) -> R -): R = IrTypeInlineClassesSupport.unwrapToPrimitiveOrReference(this, eachInlinedClass, ifPrimitive, ifReference) // TODO: consider renaming to `isReference`. fun KotlinType.binaryTypeIsReference(): Boolean = this.computePrimitiveBinaryTypeOrNull() == null -fun IrType.binaryTypeIsReference(): Boolean = this.computePrimitiveBinaryTypeOrNull() == null fun KotlinType.computePrimitiveBinaryTypeOrNull(): PrimitiveBinaryType? = this.computeBinaryType().primitiveBinaryTypeOrNull() fun KotlinType.computeBinaryType(): BinaryType = KotlinTypeInlineClassesSupport.computeBinaryType(this) -fun IrType.computePrimitiveBinaryTypeOrNull(): PrimitiveBinaryType? = - this.computeBinaryType().primitiveBinaryTypeOrNull() - -fun IrType.computeBinaryType(): BinaryType = IrTypeInlineClassesSupport.computeBinaryType(this) - -fun IrClass.inlinedClassIsNullable(): Boolean = this.defaultType.makeNullable().getInlinedClassNative() == this // TODO: optimize -fun IrClass.isUsedAsBoxClass(): Boolean = IrTypeInlineClassesSupport.isUsedAsBoxClass(this) - /** * Most "underlying" user-visible non-reference type. * It is visible as inlined to compiler for simplicity. @@ -114,14 +80,18 @@ enum class KonanPrimitiveType(val classId: ClassId, val binaryType: BinaryType.P } } -internal abstract class InlineClassesSupport { - protected abstract fun isNullable(type: Type): Boolean - protected abstract fun makeNullable(type: Type): Type +@InternalKotlinNativeApi +abstract class InlineClassesSupport { + @InternalKotlinNativeApi + abstract fun isNullable(type: Type): Boolean + @InternalKotlinNativeApi + abstract fun makeNullable(type: Type): Type protected abstract fun erase(type: Type): Class protected abstract fun computeFullErasure(type: Type): Sequence protected abstract fun hasInlineModifier(clazz: Class): Boolean protected abstract fun getNativePointedSuperclass(clazz: Class): Class? - protected abstract fun getInlinedClassUnderlyingType(clazz: Class): Type + @InternalKotlinNativeApi + abstract fun getInlinedClassUnderlyingType(clazz: Class): Type protected abstract fun getPackageFqName(clazz: Class): FqName? protected abstract fun getName(clazz: Class): Name? abstract fun isTopLevelClass(clazz: Class): Boolean @@ -135,15 +105,17 @@ internal abstract class InlineClassesSupport { fun getInlinedClass(type: Type): Class? = getInlinedClass(erase(type), isNullable(type)) - protected fun getKonanPrimitiveType(clazz: Class): KonanPrimitiveType? = + @InternalKotlinNativeApi + fun getKonanPrimitiveType(clazz: Class): KonanPrimitiveType? = if (isTopLevelClass(clazz)) KonanPrimitiveType.byFqNameParts[getPackageFqName(clazz)]?.get(getName(clazz)) else null - protected fun isImplicitInlineClass(clazz: Class): Boolean = - isTopLevelClass(clazz) && (getKonanPrimitiveType(clazz) != null || - getName(clazz) == KonanFqNames.nativePtr.shortName() && getPackageFqName(clazz) == KonanFqNames.internalPackageName || - getName(clazz) == InteropFqNames.cPointer.shortName() && getPackageFqName(clazz) == InteropFqNames.cPointer.parent().toSafe()) + @InternalKotlinNativeApi + fun isImplicitInlineClass(clazz: Class): Boolean = + isTopLevelClass(clazz) && (getKonanPrimitiveType(clazz) != null || + getName(clazz) == KonanFqNames.nativePtr.shortName() && getPackageFqName(clazz) == KonanFqNames.internalPackageName || + getName(clazz) == InteropFqNames.cPointer.shortName() && getPackageFqName(clazz) == InteropFqNames.cPointer.parent().toSafe()) private fun getInlinedClass(erased: Class, isNullable: Boolean): Class? { val inlinedClass = getInlinedClass(erased) ?: return null @@ -194,7 +166,7 @@ internal abstract class InlineClassesSupport { val nullable = isNullable(currentType) - getKonanPrimitiveType(inlinedClass)?.let { primitiveType -> + getKonanPrimitiveType(inlinedClass)?.let { primitiveType -> return ifPrimitive(primitiveType, nullable) } @@ -235,7 +207,8 @@ internal abstract class InlineClassesSupport { BinaryType.Reference(computeFullErasure(type), true) } -internal object KotlinTypeInlineClassesSupport : InlineClassesSupport() { +@InternalKotlinNativeApi +object KotlinTypeInlineClassesSupport : InlineClassesSupport() { override fun isNullable(type: KotlinType): Boolean = type.isNullable() override fun makeNullable(type: KotlinType): KotlinType = type.makeNullable() @@ -271,46 +244,3 @@ internal object KotlinTypeInlineClassesSupport : InlineClassesSupport() { - - override fun isNullable(type: IrType): Boolean = type.isNullable() - - override fun makeNullable(type: IrType): IrType = type.makeNullable() - - override tailrec fun erase(type: IrType): IrClass { - val classifier = type.classifierOrFail - return when (classifier) { - is IrClassSymbol -> classifier.owner - is IrTypeParameterSymbol -> erase(classifier.owner.superTypes.first()) - else -> error(classifier) - } - } - - override fun computeFullErasure(type: IrType): Sequence = when (val classifier = type.classifierOrFail) { - is IrClassSymbol -> sequenceOf(classifier.owner) - is IrTypeParameterSymbol -> classifier.owner.superTypes.asSequence().flatMap { computeFullErasure(it) } - is IrScriptSymbol -> classifier.unexpectedSymbolKind() - } - - override fun hasInlineModifier(clazz: IrClass): Boolean = clazz.isSingleFieldValueClass - - override fun getNativePointedSuperclass(clazz: IrClass): IrClass? { - var superClass: IrClass? = clazz - while (superClass != null && InteropFqNames.nativePointed.toSafe() != superClass.fqNameWhenAvailable) - superClass = superClass.getSuperClassNotAny() - return superClass - } - - override fun getInlinedClassUnderlyingType(clazz: IrClass): IrType = - clazz.constructors.firstOrNull { it.isPrimary }?.valueParameters?.single()?.type - ?: clazz.declarations.filterIsInstance().atMostOne { it.backingField?.takeUnless { it.isStatic } != null }?.backingField?.type - ?: clazz.inlineClassRepresentation!!.underlyingType - - override fun getPackageFqName(clazz: IrClass) = - clazz.packageFqName - - override fun getName(clazz: IrClass): Name? = - clazz.name - - override fun isTopLevelClass(clazz: IrClass): Boolean = clazz.isTopLevel -} diff --git a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InternalKotlinNativeApi.kt b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InternalKotlinNativeApi.kt new file mode 100644 index 00000000000..54b4c0173c0 --- /dev/null +++ b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InternalKotlinNativeApi.kt @@ -0,0 +1,17 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.konan + +/** + * This annotation is used to mark APIs as 'internal' to Kotlin/Native across modules within kotlin.git. + * Note: Any API with this annotation can be changed and potentially removed at any time. + * It is not safe to depend on any internal Kotlin/Native API outside kotlin.git/kotlin-native + */ +@RequiresOptIn( + "This API is internal to the Kotlin/Native compiler and cannot be used outside of kotlin.git", + level = RequiresOptIn.Level.ERROR +) +annotation class InternalKotlinNativeApi diff --git a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InteropUtils.kt b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InteropUtils.kt index b35602f4cf8..e02a5751827 100644 --- a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InteropUtils.kt +++ b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/InteropUtils.kt @@ -1,6 +1,6 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan @@ -95,7 +95,8 @@ object InteropFqNames { private fun FqName.child(nameIdent: String) = child(Name.identifier(nameIdent)) -internal class InteropBuiltIns(builtIns: KonanBuiltIns) { +@InternalKotlinNativeApi +class InteropBuiltIns(builtIns: KonanBuiltIns) { private val packageScope = builtIns.builtInsModule.getPackage(InteropFqNames.packageName).memberScope @@ -113,43 +114,3 @@ internal fun MemberScope.getContributedClass(name: String): ClassDescriptor = private fun MemberScope.getContributedFunctions(name: String) = this.getContributedFunctions(Name.identifier(name), NoLookupLocation.FROM_BUILTINS) -internal val cKeywords = setOf( - // Actual C keywords. - "auto", "break", "case", - "char", "const", "continue", - "default", "do", "double", - "else", "enum", "extern", - "float", "for", "goto", - "if", "int", "long", - "register", "return", - "short", "signed", "sizeof", "static", "struct", "switch", - "typedef", "union", "unsigned", - "void", "volatile", "while", - // C99-specific. - "_Bool", "_Complex", "_Imaginary", "inline", "restrict", - // C11-specific. - "_Alignas", "_Alignof", "_Atomic", "_Generic", "_Noreturn", "_Static_assert", "_Thread_local", - // Not exactly keywords, but reserved or standard-defined. - "and", "not", "or", "xor", - "bool", "complex", "imaginary", - - // C++ keywords not listed above. - "alignas", "alignof", "and_eq", "asm", - "bitand", "bitor", "bool", - "catch", "char16_t", "char32_t", "class", "compl", "constexpr", "const_cast", - "decltype", "delete", "dynamic_cast", - "explicit", "export", - "false", "friend", - "inline", - "mutable", - "namespace", "new", "noexcept", "not_eq", "nullptr", - "operator", "or_eq", - "private", "protected", "public", - "reinterpret_cast", - "static_assert", - "template", "this", "thread_local", "throw", "true", "try", "typeid", "typename", - "using", - "virtual", - "wchar_t", - "xor_eq" -) diff --git a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/KonanFqNames.kt b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/KonanFqNames.kt index 8445087820b..2a2e4a93877 100644 --- a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/KonanFqNames.kt +++ b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/KonanFqNames.kt @@ -1,6 +1,6 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan @@ -9,9 +9,14 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.name.NativeRuntimeNames -internal const val NATIVE_PTR_NAME = "NativePtr" -internal const val NON_NULL_NATIVE_PTR_NAME = "NonNullNativePtr" -internal const val IMMUTABLE_BLOB_OF = "immutableBlobOf" +@InternalKotlinNativeApi +const val NATIVE_PTR_NAME = "NativePtr" + +@InternalKotlinNativeApi +const val NON_NULL_NATIVE_PTR_NAME = "NonNullNativePtr" + +@InternalKotlinNativeApi +const val IMMUTABLE_BLOB_OF = "immutableBlobOf" object KonanFqNames { val function = FqName("kotlin.Function") diff --git a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/cKeywords.kt b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/cKeywords.kt new file mode 100644 index 00000000000..11e4a4727c6 --- /dev/null +++ b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/cKeywords.kt @@ -0,0 +1,48 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.konan + +@InternalKotlinNativeApi +val cKeywords = setOf( + // Actual C keywords. + "auto", "break", "case", + "char", "const", "continue", + "default", "do", "double", + "else", "enum", "extern", + "float", "for", "goto", + "if", "int", "long", + "register", "return", + "short", "signed", "sizeof", "static", "struct", "switch", + "typedef", "union", "unsigned", + "void", "volatile", "while", + // C99-specific. + "_Bool", "_Complex", "_Imaginary", "inline", "restrict", + // C11-specific. + "_Alignas", "_Alignof", "_Atomic", "_Generic", "_Noreturn", "_Static_assert", "_Thread_local", + // Not exactly keywords, but reserved or standard-defined. + "and", "not", "or", "xor", + "bool", "complex", "imaginary", + + // C++ keywords not listed above. + "alignas", "alignof", "and_eq", "asm", + "bitand", "bitor", "bool", + "catch", "char16_t", "char32_t", "class", "compl", "constexpr", "const_cast", + "decltype", "delete", "dynamic_cast", + "explicit", "export", + "false", "friend", + "inline", + "mutable", + "namespace", "new", "noexcept", "not_eq", "nullptr", + "operator", "or_eq", + "private", "protected", "public", + "reinterpret_cast", + "static_assert", + "template", "this", "thread_local", "throw", "true", "try", "typeid", "typename", + "using", + "virtual", + "wchar_t", + "xor_eq" +) diff --git a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/descriptors/LegacyDescriptorUtils.kt b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/descriptors/LegacyDescriptorUtils.kt index 0de1a8e1064..58225398a43 100644 --- a/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/descriptors/LegacyDescriptorUtils.kt +++ b/native/base/src/main/kotlin/org/jetbrains/kotlin/backend/konan/descriptors/LegacyDescriptorUtils.kt @@ -1,10 +1,11 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.descriptors +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi import org.jetbrains.kotlin.descriptors.* import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl import org.jetbrains.kotlin.name.FqName @@ -20,7 +21,8 @@ import org.jetbrains.kotlin.types.typeUtil.isUnit * * TODO: this method is actually a part of resolve and probably duplicates another one */ -internal fun T.resolveFakeOverride(allowAbstract: Boolean = false): T { +@InternalKotlinNativeApi +fun T.resolveFakeOverride(allowAbstract: Boolean = false): T { if (this.kind.isReal) { return this } else { @@ -32,19 +34,24 @@ internal fun T.resolveFakeOverride(allowAbstract: } } -internal val ClassDescriptor.isArray: Boolean +@InternalKotlinNativeApi +val ClassDescriptor.isArray: Boolean get() = this.fqNameSafe.asString() in arrayTypes -internal val ClassDescriptor.isInterface: Boolean +@InternalKotlinNativeApi +val ClassDescriptor.isInterface: Boolean get() = (this.kind == ClassKind.INTERFACE) -internal fun ClassDescriptor.isUnit() = this.defaultType.isUnit() +@InternalKotlinNativeApi +fun ClassDescriptor.isUnit() = this.defaultType.isUnit() -internal fun ClassDescriptor.isNothing() = this.defaultType.isNothing() +@InternalKotlinNativeApi +fun ClassDescriptor.isNothing() = this.defaultType.isNothing() -internal val T.allOverriddenDescriptors: List +@InternalKotlinNativeApi +val T.allOverriddenDescriptors: List get() { val result = mutableListOf() fun traverse(descriptor: T) { @@ -56,11 +63,13 @@ internal val T.allOverriddenDescriptors: List return result } -internal val ClassDescriptor.contributedMethods: List - get () = unsubstitutedMemberScope.contributedMethods +@InternalKotlinNativeApi +val ClassDescriptor.contributedMethods: List + get() = unsubstitutedMemberScope.contributedMethods -internal val MemberScope.contributedMethods: List - get () { +@InternalKotlinNativeApi +val MemberScope.contributedMethods: List + get() { val contributedDescriptors = this.getContributedDescriptors() val functions = contributedDescriptors.filterIsInstance() @@ -74,15 +83,18 @@ internal val MemberScope.contributedMethods: List fun ClassDescriptor.isAbstract() = this.modality == Modality.SEALED || this.modality == Modality.ABSTRACT -internal val FunctionDescriptor.target: FunctionDescriptor +@InternalKotlinNativeApi +val FunctionDescriptor.target: FunctionDescriptor get() = (if (modality == Modality.ABSTRACT) this else resolveFakeOverride()).original -internal fun DeclarationDescriptor.findPackageView(): PackageViewDescriptor { +@InternalKotlinNativeApi +fun DeclarationDescriptor.findPackageView(): PackageViewDescriptor { val packageFragment = this.findPackage() return packageFragment.module.getPackage(packageFragment.fqName) } -internal fun DeclarationDescriptor.allContainingDeclarations(): List { +@InternalKotlinNativeApi +fun DeclarationDescriptor.allContainingDeclarations(): List { var list = mutableListOf() var current = this.containingDeclaration while (current != null) { @@ -120,5 +132,33 @@ val ClassDescriptor.enumEntries: List .filter { it.kind == ClassKind.ENUM_ENTRY } } -internal val DeclarationDescriptor.isExpectMember: Boolean +@InternalKotlinNativeApi +val DeclarationDescriptor.isExpectMember: Boolean get() = this is MemberDescriptor && this.isExpect + +@InternalKotlinNativeApi +val arrayTypes = setOf( + "kotlin.Array", + "kotlin.ByteArray", + "kotlin.CharArray", + "kotlin.ShortArray", + "kotlin.IntArray", + "kotlin.LongArray", + "kotlin.FloatArray", + "kotlin.DoubleArray", + "kotlin.BooleanArray", + "kotlin.native.ImmutableBlob", + "kotlin.native.internal.NativePtrArray" +) + +@InternalKotlinNativeApi +val arraysWithFixedSizeItems = setOf( + "kotlin.ByteArray", + "kotlin.CharArray", + "kotlin.ShortArray", + "kotlin.IntArray", + "kotlin.LongArray", + "kotlin.FloatArray", + "kotlin.DoubleArray", + "kotlin.BooleanArray" +) \ No newline at end of file diff --git a/native/objcexport-header-generator/.editorconfig b/native/objcexport-header-generator/.editorconfig new file mode 100644 index 00000000000..93a002809be --- /dev/null +++ b/native/objcexport-header-generator/.editorconfig @@ -0,0 +1,2 @@ +[*] +ij_continuation_indent_size = 4 \ No newline at end of file diff --git a/native/objcexport-header-generator/build.gradle.kts b/native/objcexport-header-generator/build.gradle.kts new file mode 100644 index 00000000000..b67fa7bac2c --- /dev/null +++ b/native/objcexport-header-generator/build.gradle.kts @@ -0,0 +1,33 @@ +plugins { + kotlin("jvm") +} + +dependencies { + implementation(intellijCore()) + implementation(project(":compiler:cli-base")) + implementation(project(":compiler:cli-common")) + implementation(project(":compiler:ir.objcinterop")) + implementation(project(":compiler:ir.serialization.native")) + implementation(project(":core:compiler.common.native")) + implementation(project(":core:descriptors")) + implementation(project(":native:base")) + implementation(project(":native:kotlin-native-utils")) + + testImplementation(libs.junit.jupiter.api) + testImplementation(libs.junit.jupiter.params) + testImplementation(project(":compiler:tests-common", "tests-jar")) + + testRuntimeOnly(libs.junit.jupiter.engine) +} + +kotlin { + compilerOptions { + optIn.add("org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi") + } +} + +nativeTest("test", tag = null) { + useJUnitPlatform() + systemProperty("projectDir", projectDir.absolutePath) + workingDir(rootProject.projectDir) +} diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/CustomTypeMapper.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/CustomTypeMapper.kt index f752231bd1c..89a3d750518 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/CustomTypeMapper.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/CustomTypeMapper.kt @@ -1,10 +1,11 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi import org.jetbrains.kotlin.builtins.StandardNames import org.jetbrains.kotlin.builtins.functions.FunctionTypeKind import org.jetbrains.kotlin.builtins.getFunctionTypeKind @@ -15,12 +16,14 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.classId import org.jetbrains.kotlin.types.KotlinType import org.jetbrains.kotlin.types.TypeUtils -internal fun ClassDescriptor.isMappedFunctionClass() = +@InternalKotlinNativeApi +fun ClassDescriptor.isMappedFunctionClass() = this.getFunctionTypeKind() == FunctionTypeKind.Function && // Type parameters include return type. declaredTypeParameters.size - 1 < CustomTypeMappers.functionTypeMappersArityLimit -internal interface CustomTypeMapper { +@InternalKotlinNativeApi +interface CustomTypeMapper { val mappedClassId: ClassId fun mapType(mappedSuperType: KotlinType, translator: ObjCExportTranslatorImpl, objCExportScope: ObjCExportScope): ObjCNonNullReferenceType } diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/MainPackageGuesser.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/MainPackageGuesser.kt index c16d8f6d105..8a3d0d0c881 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/MainPackageGuesser.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/MainPackageGuesser.kt @@ -5,6 +5,7 @@ package org.jetbrains.kotlin.backend.konan.objcexport +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi import org.jetbrains.kotlin.backend.konan.descriptors.getPackageFragments import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.name.FqName @@ -14,7 +15,8 @@ import org.jetbrains.kotlin.name.isSubpackageOf * Tries to infer a main package name that can be used * for bundle ID of a framework. */ -internal class MainPackageGuesser { +@InternalKotlinNativeApi +class MainPackageGuesser { fun guess( moduleDescriptor: ModuleDescriptor, includedLibraryDescriptors: List, diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/MethodBridge.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/MethodBridge.kt index b92b3698ca3..4101bbd772b 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/MethodBridge.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/MethodBridge.kt @@ -1,44 +1,55 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport import org.jetbrains.kotlin.backend.common.descriptors.allParameters +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.ParameterDescriptor import org.jetbrains.kotlin.ir.declarations.IrFunction import org.jetbrains.kotlin.ir.declarations.IrValueParameter import org.jetbrains.kotlin.ir.util.allParameters -internal sealed class TypeBridge -internal object ReferenceBridge : TypeBridge() +@InternalKotlinNativeApi +sealed class TypeBridge -internal data class BlockPointerBridge( +@InternalKotlinNativeApi +object ReferenceBridge : TypeBridge() + +@InternalKotlinNativeApi +data class BlockPointerBridge( val numberOfParameters: Int, val returnsVoid: Boolean ) : TypeBridge() -internal data class ValueTypeBridge(val objCValueType: ObjCValueType) : TypeBridge() +@InternalKotlinNativeApi +data class ValueTypeBridge(val objCValueType: ObjCValueType) : TypeBridge() -internal sealed class MethodBridgeParameter +@InternalKotlinNativeApi +sealed class MethodBridgeParameter -internal sealed class MethodBridgeReceiver : MethodBridgeParameter() { +@InternalKotlinNativeApi +sealed class MethodBridgeReceiver : MethodBridgeParameter() { object Static : MethodBridgeReceiver() object Factory : MethodBridgeReceiver() object Instance : MethodBridgeReceiver() } -internal object MethodBridgeSelector : MethodBridgeParameter() +@InternalKotlinNativeApi +object MethodBridgeSelector : MethodBridgeParameter() -internal sealed class MethodBridgeValueParameter : MethodBridgeParameter() { +@InternalKotlinNativeApi +sealed class MethodBridgeValueParameter : MethodBridgeParameter() { data class Mapped(val bridge: TypeBridge) : MethodBridgeValueParameter() object ErrorOutParameter : MethodBridgeValueParameter() data class SuspendCompletion(val useUnitCompletion: Boolean) : MethodBridgeValueParameter() } -internal data class MethodBridge( +@InternalKotlinNativeApi +data class MethodBridge( val returnBridge: ReturnValue, val receiver: MethodBridgeReceiver, val valueParameters: List @@ -76,7 +87,8 @@ internal data class MethodBridge( get() = returnBridge is ReturnValue.WithError } -internal fun MethodBridge.valueParametersAssociated( +@InternalKotlinNativeApi +fun MethodBridge.valueParametersAssociated( descriptor: FunctionDescriptor ): List> { val kotlinParameters = descriptor.allParameters.iterator() @@ -97,26 +109,3 @@ internal fun MethodBridge.valueParametersAssociated( } }.also { assert(!kotlinParameters.hasNext()) } } - -internal fun MethodBridge.parametersAssociated( - irFunction: IrFunction -): List> { - val kotlinParameters = irFunction.allParameters.iterator() - - return this.paramBridges.map { - when (it) { - is MethodBridgeValueParameter.Mapped, - MethodBridgeReceiver.Instance, - is MethodBridgeValueParameter.SuspendCompletion -> - it to kotlinParameters.next() - - MethodBridgeReceiver.Static, MethodBridgeSelector, MethodBridgeValueParameter.ErrorOutParameter -> - it to null - - MethodBridgeReceiver.Factory -> { - kotlinParameters.next() - it to null - } - } - }.also { assert(!kotlinParameters.hasNext()) } -} diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt index 5a279de145a..595ea199538 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGenerator.kt @@ -1,6 +1,6 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport @@ -52,12 +52,13 @@ interface ObjCExportProblemCollector { } } -internal class ObjCExportTranslatorImpl( - private val generator: ObjCExportHeaderGenerator?, - val mapper: ObjCExportMapper, - val namer: ObjCExportNamer, - val problemCollector: ObjCExportProblemCollector, - val objcGenerics: Boolean +@InternalKotlinNativeApi +class ObjCExportTranslatorImpl( + private val generator: ObjCExportHeaderGenerator?, + val mapper: ObjCExportMapper, + val namer: ObjCExportNamer, + val problemCollector: ObjCExportProblemCollector, + val objcGenerics: Boolean ) : ObjCExportTranslator { private val kotlinAnyName = namer.kotlinAnyName @@ -1096,12 +1097,12 @@ internal class ObjCExportTranslatorImpl( StubBuilder(problemCollector).apply(block).build() } -abstract class ObjCExportHeaderGenerator internal constructor( - val moduleDescriptors: List, - internal val mapper: ObjCExportMapper, - val namer: ObjCExportNamer, - val objcGenerics: Boolean, - problemCollector: ObjCExportProblemCollector +abstract class ObjCExportHeaderGenerator @InternalKotlinNativeApi constructor( + val moduleDescriptors: List, + internal val mapper: ObjCExportMapper, + val namer: ObjCExportNamer, + val objcGenerics: Boolean, + problemCollector: ObjCExportProblemCollector ) { private val stubs = mutableListOf>() @@ -1173,7 +1174,8 @@ abstract class ObjCExportHeaderGenerator internal constructor( add("NS_ASSUME_NONNULL_END") } - internal fun buildInterface(): ObjCExportedInterface { + @InternalKotlinNativeApi + fun buildInterface(): ObjCExportedInterface { val headerLines = build() return ObjCExportedInterface(generatedClasses, extensions, topLevel, headerLines, namer, mapper) } @@ -1356,6 +1358,18 @@ abstract class ObjCExportHeaderGenerator internal constructor( add("#import <$it>") } } + + fun createInstance( + moduleDescriptors: List, + mapper: ObjCExportMapper, + namer: ObjCExportNamer, + problemCollector: ObjCExportProblemCollector, + objcGenerics: Boolean, + shouldExportKDoc: Boolean, + additionalImports: List, + ): ObjCExportHeaderGenerator = ObjCExportHeaderGeneratorImpl( + moduleDescriptors, mapper, namer, problemCollector, objcGenerics, shouldExportKDoc, additionalImports + ) } } @@ -1423,7 +1437,8 @@ private fun computeSuperClassType(descriptor: ClassDescriptor): KotlinType? = internal const val OBJC_SUBCLASSING_RESTRICTED = "objc_subclassing_restricted" -internal fun ClassDescriptor.needCompanionObjectProperty(namer: ObjCExportNamer, mapper: ObjCExportMapper): Boolean { +@InternalKotlinNativeApi +fun ClassDescriptor.needCompanionObjectProperty(namer: ObjCExportNamer, mapper: ObjCExportMapper): Boolean { val companionObject = companionObjectDescriptor if (companionObject == null || !mapper.shouldBeExposed(companionObject)) return false diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGeneratorImpl.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGeneratorImpl.kt index 60a0cefcf44..df98ea8c368 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGeneratorImpl.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportHeaderGeneratorImpl.kt @@ -1,54 +1,21 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport -import org.jetbrains.kotlin.backend.konan.KonanConfigKeys -import org.jetbrains.kotlin.backend.konan.driver.PhaseContext -import org.jetbrains.kotlin.backend.konan.reportCompilationWarning -import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity -import org.jetbrains.kotlin.cli.common.messages.MessageUtil -import org.jetbrains.kotlin.descriptors.DeclarationDescriptor -import org.jetbrains.kotlin.descriptors.DeclarationDescriptorWithSource -import org.jetbrains.kotlin.descriptors.FunctionDescriptor import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.renderer.DescriptorRenderer -import org.jetbrains.kotlin.resolve.source.getPsi internal class ObjCExportHeaderGeneratorImpl( - val context: PhaseContext, moduleDescriptors: List, mapper: ObjCExportMapper, namer: ObjCExportNamer, problemCollector: ObjCExportProblemCollector, - objcGenerics: Boolean + objcGenerics: Boolean, + override val shouldExportKDoc: Boolean, + private val additionalImports: List, ) : ObjCExportHeaderGenerator(moduleDescriptors, mapper, namer, objcGenerics, problemCollector) { - - override val shouldExportKDoc = context.shouldExportKDoc() - - internal class ProblemCollector(val context: PhaseContext) : ObjCExportProblemCollector { - override fun reportWarning(text: String) { - context.reportCompilationWarning(text) - } - - override fun reportWarning(declaration: DeclarationDescriptor, text: String) { - val psi = (declaration as? DeclarationDescriptorWithSource)?.source?.getPsi() - ?: return reportWarning( - "$text\n (at ${DescriptorRenderer.COMPACT_WITH_SHORT_TYPES.render(declaration)})" - ) - - val location = MessageUtil.psiElementToMessageLocation(psi) - - context.messageCollector.report(CompilerMessageSeverity.WARNING, text, location) - } - - override fun reportException(throwable: Throwable) { - throw throwable - } - } - override fun getAdditionalImports(): List = - context.config.configuration.getNotNull(KonanConfigKeys.FRAMEWORK_IMPORT_HEADERS) + additionalImports } diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportLazy.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportLazy.kt index bc1ec025117..f01d91c6c6f 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportLazy.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportLazy.kt @@ -1,12 +1,13 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport import com.intellij.psi.PsiElement import org.jetbrains.kotlin.analyzer.ModuleInfo +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi import org.jetbrains.kotlin.backend.konan.UnitSuspendFunctionObjCExport import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib import org.jetbrains.kotlin.builtins.KotlinBuiltIns @@ -79,7 +80,8 @@ fun createObjCExportLazy( deprecationResolver ) -internal class ObjCExportLazyImpl( +@InternalKotlinNativeApi +class ObjCExportLazyImpl( private val configuration: ObjCExportLazy.Configuration, problemCollector: ObjCExportProblemCollector, private val codeAnalyzer: KotlinCodeAnalyzer, diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportLazyUtils.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportLazyUtils.kt index 31882ebc524..7d21f04654e 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportLazyUtils.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportLazyUtils.kt @@ -1,14 +1,16 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi import org.jetbrains.kotlin.konan.file.File import org.jetbrains.kotlin.psi.KtFile -internal fun ObjCExportLazy.dumpObjCHeader(files: Collection, outputFile: String, shouldExportKDoc: Boolean) { +@InternalKotlinNativeApi +fun ObjCExportLazy.dumpObjCHeader(files: Collection, outputFile: String, shouldExportKDoc: Boolean) { val lines = (this.generateBase() + files.flatMap { this.translate(it) }) .flatMap { StubRenderer.render(it, shouldExportKDoc) + listOf("") } diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt index b3f615d15e3..f61aed9a49d 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportMapper.kt @@ -1,6 +1,6 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport @@ -25,10 +25,11 @@ import org.jetbrains.kotlin.types.TypeUtils import org.jetbrains.kotlin.types.typeUtil.isNothing import org.jetbrains.kotlin.types.typeUtil.isUnit -internal class ObjCExportMapper( - internal val deprecationResolver: DeprecationResolver? = null, - private val local: Boolean = false, - internal val unitSuspendFunctionExport: UnitSuspendFunctionObjCExport +@InternalKotlinNativeApi +class ObjCExportMapper( + internal val deprecationResolver: DeprecationResolver? = null, + private val local: Boolean = false, + internal val unitSuspendFunctionExport: UnitSuspendFunctionObjCExport ) { fun getCustomTypeMapper(descriptor: ClassDescriptor): CustomTypeMapper? = CustomTypeMappers.getMapper(descriptor) @@ -89,7 +90,8 @@ private fun isComponentNMethod(method: CallableMemberDescriptor): Boolean { } // Note: partially duplicated in ObjCExportLazyImpl.translateTopLevels. -internal fun ObjCExportMapper.shouldBeExposed(descriptor: CallableMemberDescriptor): Boolean = when { +@InternalKotlinNativeApi +fun ObjCExportMapper.shouldBeExposed(descriptor: CallableMemberDescriptor): Boolean = when { !descriptor.isEffectivelyPublicApi -> false descriptor.isExpect -> false isHiddenByDeprecation(descriptor) -> false @@ -208,29 +210,33 @@ private fun ObjCExportMapper.isBase(descriptor: CallableMemberDescriptor): Boole * ``` * Interface `I` is not exposed to the generated header, so C#f is considered to be a base method even though it has an "override" keyword. */ -internal fun ObjCExportMapper.isBaseMethod(descriptor: FunctionDescriptor) = - this.isBase(descriptor) +@InternalKotlinNativeApi +fun ObjCExportMapper.isBaseMethod(descriptor: FunctionDescriptor) = + this.isBase(descriptor) -internal fun ObjCExportMapper.getBaseMethods(descriptor: FunctionDescriptor): List = - if (isBaseMethod(descriptor)) { - listOf(descriptor) - } else { - descriptor.overriddenDescriptors.filter { shouldBeExposed(it) } - .flatMap { getBaseMethods(it.original)} - .distinct() - } +@InternalKotlinNativeApi +fun ObjCExportMapper.getBaseMethods(descriptor: FunctionDescriptor): List = + if (isBaseMethod(descriptor)) { + listOf(descriptor) + } else { + descriptor.overriddenDescriptors.filter { shouldBeExposed(it) } + .flatMap { getBaseMethods(it.original) } + .distinct() + } -internal fun ObjCExportMapper.isBaseProperty(descriptor: PropertyDescriptor) = - isBase(descriptor) +@InternalKotlinNativeApi +fun ObjCExportMapper.isBaseProperty(descriptor: PropertyDescriptor) = + isBase(descriptor) -internal fun ObjCExportMapper.getBaseProperties(descriptor: PropertyDescriptor): List = - if (isBaseProperty(descriptor)) { - listOf(descriptor) - } else { - descriptor.overriddenDescriptors - .flatMap { getBaseProperties(it.original) } - .distinct() - } +@InternalKotlinNativeApi +fun ObjCExportMapper.getBaseProperties(descriptor: PropertyDescriptor): List = + if (isBaseProperty(descriptor)) { + listOf(descriptor) + } else { + descriptor.overriddenDescriptors + .flatMap { getBaseProperties(it.original) } + .distinct() + } @Suppress("NO_TAIL_CALLS_FOUND", "NON_TAIL_RECURSIVE_CALL") // K2 warning suppression, TODO: KT-62472 internal tailrec fun KotlinType.getErasedTypeClass(): ClassDescriptor = @@ -242,7 +248,8 @@ internal fun ObjCExportMapper.isTopLevel(descriptor: CallableMemberDescriptor): internal fun ObjCExportMapper.isObjCProperty(property: PropertyDescriptor): Boolean = property.extensionReceiverParameter == null || getClassIfCategory(property) != null -internal fun ClassDescriptor.getEnumValuesFunctionDescriptor(): SimpleFunctionDescriptor? { +@InternalKotlinNativeApi +fun ClassDescriptor.getEnumValuesFunctionDescriptor(): SimpleFunctionDescriptor? { require(this.kind == ClassKind.ENUM_CLASS) return this.staticScope.getContributedFunctions( @@ -251,7 +258,8 @@ internal fun ClassDescriptor.getEnumValuesFunctionDescriptor(): SimpleFunctionDe ).singleOrNull { it.extensionReceiverParameter == null && it.valueParameters.size == 0 } } -internal fun ClassDescriptor.getEnumEntriesPropertyDescriptor(): PropertyDescriptor? { +@InternalKotlinNativeApi +fun ClassDescriptor.getEnumEntriesPropertyDescriptor(): PropertyDescriptor? { require(this.kind == ClassKind.ENUM_CLASS) return this.staticScope.getContributedVariables( @@ -312,7 +320,7 @@ private fun ObjCExportMapper.bridgeFunctionType(kotlinType: KotlinType): TypeBri } private fun ObjCExportMapper.bridgeParameter(parameter: ParameterDescriptor): MethodBridgeValueParameter = - MethodBridgeValueParameter.Mapped(bridgeType(parameter.type)) + MethodBridgeValueParameter.Mapped(bridgeType(parameter.type)) private fun ObjCExportMapper.bridgeReturnType( descriptor: FunctionDescriptor, @@ -427,7 +435,8 @@ internal fun ObjCExportMapper.bridgePropertyType(descriptor: PropertyDescriptor) return bridgeType(descriptor.type) } -internal enum class NSNumberKind(val mappedKotlinClassId: ClassId?, val objCType: ObjCType) { +@InternalKotlinNativeApi +enum class NSNumberKind(val mappedKotlinClassId: ClassId?, val objCType: ObjCType) { CHAR(PrimitiveType.BYTE, ObjCPrimitiveType.char), UNSIGNED_CHAR(UnsignedType.UBYTE, ObjCPrimitiveType.unsigned_char), SHORT(PrimitiveType.SHORT, ObjCPrimitiveType.short), diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportNamer.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportNamer.kt index 2d5ab74e8e7..aa8a2030427 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportNamer.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportNamer.kt @@ -1,20 +1,20 @@ /* - * 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. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport import org.jetbrains.kotlin.backend.common.serialization.findSourceFile -import org.jetbrains.kotlin.backend.konan.* +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi +import org.jetbrains.kotlin.backend.konan.KonanFqNames +import org.jetbrains.kotlin.backend.konan.UnitSuspendFunctionObjCExport import org.jetbrains.kotlin.backend.konan.cKeywords import org.jetbrains.kotlin.backend.konan.descriptors.isArray import org.jetbrains.kotlin.backend.konan.descriptors.isInterface -import org.jetbrains.kotlin.backend.konan.driver.PhaseContext -import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib import org.jetbrains.kotlin.builtins.KotlinBuiltIns import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.descriptors.konan.* +import org.jetbrains.kotlin.descriptors.konan.isNativeStdlib import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.library.metadata.CurrentKlibModuleOrigin import org.jetbrains.kotlin.library.metadata.DeserializedKlibModuleOrigin @@ -88,9 +88,12 @@ interface ObjCExportNamer { fun getCompanionObjectPropertySelector(descriptor: ClassDescriptor): String companion object { - internal const val kotlinThrowableAsErrorMethodName: String = "asError" - internal const val objectPropertyName: String = "shared" - internal const val companionObjectPropertyName: String = "companion" + @InternalKotlinNativeApi + const val kotlinThrowableAsErrorMethodName: String = "asError" + @InternalKotlinNativeApi + const val objectPropertyName: String = "shared" + @InternalKotlinNativeApi + const val companionObjectPropertyName: String = "companion" } } @@ -273,14 +276,14 @@ private class ObjCExportNamingHelper( "char", "long", "float", "double", "int32_t", "int64_t", "int16_t", "int8_t", "unichar") } -internal class ObjCExportNamerImpl( +@InternalKotlinNativeApi +class ObjCExportNamerImpl( private val configuration: ObjCExportNamer.Configuration, builtIns: KotlinBuiltIns, private val mapper: ObjCExportMapper, private val problemCollector: ObjCExportProblemCollector, private val local: Boolean ) : ObjCExportNamer { - constructor( moduleDescriptors: Set, builtIns: KotlinBuiltIns, @@ -703,7 +706,7 @@ internal class ObjCExportNamerImpl( builtIns.mutableMap to mutableMapName ) - predefinedClassNames.forEach { descriptor, name -> + predefinedClassNames.forEach { (descriptor, name) -> objCClassNames.forceAssign(descriptor, name.objCName) swiftClassAndProtocolNames.forceAssign(descriptor, name.swiftName) } @@ -714,11 +717,11 @@ internal class ObjCExportNamerImpl( NoLookupLocation.FROM_BACKEND ).single() - Predefined.anyMethodSelectors.forEach { name, selector -> + Predefined.anyMethodSelectors.forEach { (name, selector) -> methodSelectors.forceAssign(any.method(name), selector) } - Predefined.anyMethodSwiftNames.forEach { name, swiftName -> + Predefined.anyMethodSwiftNames.forEach { (name, swiftName) -> methodSwiftNames.forceAssign(any.method(name), swiftName) } } @@ -1082,8 +1085,6 @@ internal val ModuleDescriptor.objCExportAdditionalNamePrefix: String get() { return abbreviate(fullPrefix) } -internal val PhaseContext.objCExportTopLevelNamePrefix: String - get() = abbreviate(config.fullExportedNamePrefix) fun abbreviate(name: String): String { val normalizedName = name diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportScope.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportScope.kt index 4a008a0e01d..daee7d38492 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportScope.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportScope.kt @@ -1,10 +1,11 @@ /* - * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package org.jetbrains.kotlin.backend.konan.objcexport +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi import org.jetbrains.kotlin.backend.konan.descriptors.isInterface import org.jetbrains.kotlin.descriptors.ClassDescriptor import org.jetbrains.kotlin.descriptors.DeclarationDescriptor @@ -35,7 +36,8 @@ internal inline fun ObjCExportScope.nearestScopeOf return null } -internal object ObjCRootExportScope : ObjCExportScope +@InternalKotlinNativeApi +object ObjCRootExportScope : ObjCExportScope interface ObjCClassExportScope : ObjCExportScope { fun getGenericTypeUsage(typeParameterDescriptor: TypeParameterDescriptor?): ObjCGenericTypeUsage? diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportedInterface.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportedInterface.kt new file mode 100644 index 00000000000..ea02f1a1a9e --- /dev/null +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/ObjCExportedInterface.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.backend.konan.objcexport + +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi +import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.descriptors.SourceFile + +@InternalKotlinNativeApi +class ObjCExportedInterface internal constructor( + val generatedClasses: Set, + val categoryMembers: Map>, + val topLevel: Map>, + val headerLines: List, + val namer: ObjCExportNamer, + val mapper: ObjCExportMapper +) \ No newline at end of file diff --git a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/objcTypes.kt b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/objcTypes.kt index 38c5f84bcd7..8740c604144 100644 --- a/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/objcTypes.kt +++ b/native/objcexport-header-generator/src/main/kotlin/org/jetbrains/kotlin/backend/konan/objcexport/objcTypes.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.backend.konan.objcexport -import org.jetbrains.kotlin.backend.konan.llvm.LlvmParameterAttribute +import org.jetbrains.kotlin.backend.konan.InternalKotlinNativeApi import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.types.Variance @@ -154,16 +154,17 @@ object ObjCVoidType : ObjCType() { override fun render(attrsAndName: String) = "void".withAttrsAndName(attrsAndName) } -internal enum class ObjCValueType(val encoding: String, val defaultParameterAttributes: List = emptyList()) { - BOOL("c", listOf(LlvmParameterAttribute.SignExt)), - UNICHAR("S", listOf(LlvmParameterAttribute.ZeroExt)), +@InternalKotlinNativeApi +enum class ObjCValueType(val encoding: String) { + BOOL("c"), + UNICHAR("S"), // TODO: Switch to explicit SIGNED_CHAR - CHAR("c", listOf(LlvmParameterAttribute.SignExt)), - SHORT("s", listOf(LlvmParameterAttribute.SignExt)), + CHAR("c"), + SHORT("s"), INT("i"), LONG_LONG("q"), - UNSIGNED_CHAR("C", listOf(LlvmParameterAttribute.ZeroExt)), - UNSIGNED_SHORT("S", listOf(LlvmParameterAttribute.ZeroExt)), + UNSIGNED_CHAR("C"), + UNSIGNED_SHORT("S"), UNSIGNED_INT("I"), UNSIGNED_LONG_LONG("Q"), FLOAT("f"), @@ -206,7 +207,8 @@ data class ObjCGenericTypeParameterDeclaration( get() = ObjCVariance.fromKotlinVariance(typeParameterDescriptor.variance) } -internal fun ObjCType.makeNullableIfReferenceOrPointer(): ObjCType = when (this) { +@InternalKotlinNativeApi +fun ObjCType.makeNullableIfReferenceOrPointer(): ObjCType = when (this) { is ObjCPointerType -> ObjCPointerType(this.pointee, nullable = true) is ObjCNonNullReferenceType -> ObjCNullableReferenceType(this) diff --git a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/Fe10ObjCExportHeaderGenerator.kt b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/Fe10ObjCExportHeaderGenerator.kt index eda60e4602a..d11487224cd 100644 --- a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/Fe10ObjCExportHeaderGenerator.kt +++ b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/Fe10ObjCExportHeaderGenerator.kt @@ -6,43 +6,11 @@ package org.jetbrains.kotlin.backend.konan.testUtils import com.intellij.openapi.Disposable -import org.jetbrains.kotlin.analyzer.ModuleInfo -import org.jetbrains.kotlin.analyzer.common.CommonDependenciesContainer -import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory -import org.jetbrains.kotlin.backend.konan.KlibFactories -import org.jetbrains.kotlin.backend.konan.KonanConfig -import org.jetbrains.kotlin.backend.konan.KonanConfigKeys -import org.jetbrains.kotlin.backend.konan.KonanConfigKeys.Companion.KONAN_HOME import org.jetbrains.kotlin.backend.konan.UnitSuspendFunctionObjCExport -import org.jetbrains.kotlin.backend.konan.driver.BasicPhaseContext import org.jetbrains.kotlin.backend.konan.objcexport.* -import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportHeaderGeneratorImpl -import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportMapper -import org.jetbrains.kotlin.backend.konan.objcexport.ObjCExportNamerImpl import org.jetbrains.kotlin.builtins.DefaultBuiltIns -import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys -import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments -import org.jetbrains.kotlin.cli.common.createFlexiblePhaseConfig -import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment -import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.descriptors.ModuleDescriptor -import org.jetbrains.kotlin.descriptors.PackageFragmentProvider -import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl -import org.jetbrains.kotlin.konan.target.CompilerOutputKind -import org.jetbrains.kotlin.library.resolveSingleFileKlib -import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.platform.CommonPlatforms -import org.jetbrains.kotlin.platform.TargetPlatform -import org.jetbrains.kotlin.platform.konan.NativePlatforms -import org.jetbrains.kotlin.psi.KtPsiFactory -import org.jetbrains.kotlin.resolve.CompilerEnvironment -import org.jetbrains.kotlin.resolve.PlatformDependentAnalyzerServices -import org.jetbrains.kotlin.resolve.konan.platform.NativePlatformAnalyzerServices -import org.jetbrains.kotlin.storage.LockBasedStorageManager -import org.jetbrains.kotlin.test.KotlinTestUtils -import org.jetbrains.kotlin.test.testFramework.MockProjectEx -import org.jetbrains.kotlin.test.util.KtTestUtil import java.io.File object Fe10ObjCExportHeaderGenerator : AbstractObjCExportHeaderGeneratorTest.ObjCExportHeaderGenerator { @@ -70,19 +38,17 @@ object Fe10ObjCExportHeaderGenerator : AbstractObjCExportHeaderGeneratorTest.Obj ) val environment: KotlinCoreEnvironment = createKotlinCoreEnvironment(disposable) - val phaseContext = BasicPhaseContext( - KonanConfig(environment.project, environment.configuration) - ) val kotlinFiles = root.walkTopDown().filter { it.isFile }.filter { it.extension == "kt" }.toList() return ObjCExportHeaderGeneratorImpl( - context = phaseContext, moduleDescriptors = listOf(createModuleDescriptor(environment, kotlinFiles)), mapper = mapper, namer = namer, problemCollector = ObjCExportProblemCollector.SILENT, - objcGenerics = true + objcGenerics = true, + shouldExportKDoc = true, + additionalImports = emptyList() ) } } \ No newline at end of file diff --git a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/Fe10Utils.kt b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/Fe10Utils.kt index 6ca5300ce9f..3d1387ec799 100644 --- a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/Fe10Utils.kt +++ b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/Fe10Utils.kt @@ -9,9 +9,9 @@ import com.intellij.openapi.Disposable import org.jetbrains.kotlin.analyzer.ModuleInfo import org.jetbrains.kotlin.analyzer.common.CommonDependenciesContainer import org.jetbrains.kotlin.analyzer.common.CommonResolverForModuleFactory -import org.jetbrains.kotlin.backend.konan.KlibFactories -import org.jetbrains.kotlin.backend.konan.KonanConfigKeys +import org.jetbrains.kotlin.backend.common.serialization.metadata.DynamicTypeDeserializer import org.jetbrains.kotlin.builtins.DefaultBuiltIns +import org.jetbrains.kotlin.builtins.konan.KonanBuiltIns import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys import org.jetbrains.kotlin.cli.common.arguments.K2NativeCompilerArguments import org.jetbrains.kotlin.cli.common.createFlexiblePhaseConfig @@ -21,7 +21,7 @@ import org.jetbrains.kotlin.config.* import org.jetbrains.kotlin.descriptors.ModuleDescriptor import org.jetbrains.kotlin.descriptors.PackageFragmentProvider import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl -import org.jetbrains.kotlin.konan.target.CompilerOutputKind +import org.jetbrains.kotlin.library.metadata.KlibMetadataFactories import org.jetbrains.kotlin.library.resolveSingleFileKlib import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.platform.CommonPlatforms @@ -87,13 +87,6 @@ private fun createCompilerConfiguration(): CompilerConfiguration { val configuration = KotlinTestUtils.newConfiguration() configuration.put(CommonConfigurationKeys.LANGUAGE_VERSION_SETTINGS, createLanguageVersionSettings()) configuration.put(CLIConfigurationKeys.FLEXIBLE_PHASE_CONFIG, createFlexiblePhaseConfig(K2NativeCompilerArguments())) - configuration.put(KonanConfigKeys.KONAN_HOME, konanHomePath) - configuration.put(KonanConfigKeys.PRODUCE, CompilerOutputKind.FRAMEWORK) - configuration.put(KonanConfigKeys.AUTO_CACHEABLE_FROM, emptyList()) - configuration.put(KonanConfigKeys.CACHE_DIRECTORIES, emptyList()) - configuration.put(KonanConfigKeys.CACHED_LIBRARIES, emptyMap()) - configuration.put(KonanConfigKeys.FRAMEWORK_IMPORT_HEADERS, emptyList()) - configuration.put(KonanConfigKeys.EXPORT_KDOC, true) return configuration } @@ -109,7 +102,9 @@ private object DependenciesContainerImpl : CommonDependenciesContainer { override fun registerDependencyForAllModules(moduleInfo: ModuleInfo, descriptorForModule: ModuleDescriptorImpl) = Unit override fun packageFragmentProviderForModuleInfo(moduleInfo: ModuleInfo): PackageFragmentProvider? = null - private val stdlibModuleDescriptor = KlibFactories.DefaultDeserializedDescriptorFactory.createDescriptor( + private val klibFactory = KlibMetadataFactories(::KonanBuiltIns, DynamicTypeDeserializer) + + private val stdlibModuleDescriptor = klibFactory.DefaultDeserializedDescriptorFactory.createDescriptor( library = resolveSingleFileKlib(org.jetbrains.kotlin.konan.file.File("$konanHomePath/klib/common/stdlib")), languageVersionSettings = createLanguageVersionSettings(), builtIns = DefaultBuiltIns.Instance, diff --git a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/konanHome.kt b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/konanHome.kt index 029bda5237e..c7ebfd4a4ea 100644 --- a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/konanHome.kt +++ b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/konanHome.kt @@ -5,7 +5,7 @@ package org.jetbrains.kotlin.backend.konan.testUtils -private const val konanHomePropertyKey = "org.jetbrains.kotlin.native.home" +private const val konanHomePropertyKey = "kotlin.internal.native.test.nativeHome" val konanHomePath: String get() = System.getProperty(konanHomePropertyKey) ?: error("Missing System property: '$konanHomePropertyKey'") \ No newline at end of file diff --git a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/testDataDir.kt b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/testDataDir.kt index f6b38aa19f4..8a7e32c9f5a 100644 --- a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/testDataDir.kt +++ b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/testUtils/testDataDir.kt @@ -7,5 +7,5 @@ package org.jetbrains.kotlin.backend.konan.testUtils import java.io.File -val projectDir = File("kotlin-native/backend.native") -val testDataDir = projectDir.resolve("functionalTest/testData") \ No newline at end of file +val projectDir = File(System.getProperty("projectDir")) +val testDataDir = projectDir.resolve("src/test/testData") \ No newline at end of file diff --git a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/tests/ObjCExportMapperTest.kt b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/tests/ObjCExportMapperTest.kt index e366036e4c4..e9d0f5b1db2 100644 --- a/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/tests/ObjCExportMapperTest.kt +++ b/native/objcexport-header-generator/src/test/kotlin/org/jetbrains/kotlin/backend/konan/tests/ObjCExportMapperTest.kt @@ -6,8 +6,6 @@ package org.jetbrains.kotlin.backend.konan.tests import com.intellij.openapi.util.Disposer -import org.jetbrains.kotlin.backend.konan.KonanConfig -import org.jetbrains.kotlin.backend.konan.driver.BasicPhaseContext import org.jetbrains.kotlin.backend.konan.objcexport.* import org.jetbrains.kotlin.backend.konan.testUtils.* import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment @@ -68,14 +66,13 @@ class ObjCExportMapperTest : InlineSourceTestEnvironment { val objcExportTranslator = ObjCExportTranslatorImpl( generator = ObjCExportHeaderGeneratorImpl( - context = BasicPhaseContext( - KonanConfig(kotlinCoreEnvironment.project, kotlinCoreEnvironment.configuration) - ), moduleDescriptors = listOf(module), mapper = objcExportMapper, namer = objcExportNamer, problemCollector = ObjCExportProblemCollector.SILENT, - objcGenerics = true + objcGenerics = true, + shouldExportKDoc = false, + additionalImports = emptyList() ), mapper = objcExportMapper, namer = objcExportNamer, diff --git a/prepare/ide-plugin-dependencies/kotlin-objcexport-header-generator-for-ide/build.gradle.kts b/prepare/ide-plugin-dependencies/kotlin-objcexport-header-generator-for-ide/build.gradle.kts new file mode 100644 index 00000000000..d312f3848bf --- /dev/null +++ b/prepare/ide-plugin-dependencies/kotlin-objcexport-header-generator-for-ide/build.gradle.kts @@ -0,0 +1,11 @@ +plugins { + kotlin("jvm") +} + +publishJarsForIde( + listOf( + ":native:base", + ":native:objcexport-header-generator", + ":compiler:ir.serialization.native" + ) +) diff --git a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/tasks.kt b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/tasks.kt index 6c52bde979b..c61bcb6e5c5 100644 --- a/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/tasks.kt +++ b/repo/gradle-build-conventions/buildsrc-compat/src/main/kotlin/tasks.kt @@ -103,16 +103,6 @@ enum class JUnitMode { JUnit4, JUnit5 } -/** - * Convenience function to expose Project.projectTest for groovy - */ -fun projectTest(project: Project) = project.projectTest() - -/** - * Convenience function to expose Project.projectTest for groovy - */ -fun projectTest(project: Project, jUnitMode: JUnitMode) = project.projectTest(jUnitMode = jUnitMode) - /** * @param parallel is redundant if @param jUnit5Enabled is true, because * JUnit5 supports parallel test execution by itself, without gradle help diff --git a/settings.gradle b/settings.gradle index 4166aab08cd..c57ad2ec023 100644 --- a/settings.gradle +++ b/settings.gradle @@ -110,6 +110,8 @@ include ":benchmarks", ":native:kotlin-klib-commonizer-api", ":native:kotlin-klib-commonizer-embeddable", ":native:executors", + ":native:base", + ":native:objcexport-header-generator", ":core:compiler.common", ":core:compiler.common.jvm", ":core:compiler.common.js", @@ -365,7 +367,7 @@ if (!buildProperties.inJpsBuildIdeaSync) { ":prepare:ide-plugin-dependencies:assignment-compiler-plugin-for-ide", ":prepare:ide-plugin-dependencies:parcelize-compiler-plugin-for-ide", ":prepare:ide-plugin-dependencies:lombok-compiler-plugin-for-ide", - ":prepare:ide-plugin-dependencies:kotlin-backend-native-for-ide", + ":prepare:ide-plugin-dependencies:kotlin-objcexport-header-generator-for-ide", ":prepare:ide-plugin-dependencies:tests-common-tests-for-ide", ":prepare:ide-plugin-dependencies:kotlin-compiler-testdata-for-ide", ":prepare:ide-plugin-dependencies:kotlin-compiler-tests-for-ide",