diff --git a/compiler-plugin/compiler-plugin-backend/src/main/v_2_2/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt b/compiler-plugin/compiler-plugin-backend/src/main/v_2_2/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt new file mode 100644 index 000000000..1f3c7ab42 --- /dev/null +++ b/compiler-plugin/compiler-plugin-backend/src/main/v_2_2/kotlinx/rpc/codegen/VersionSpecificApiImpl.kt @@ -0,0 +1,136 @@ +/* + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + */ + +package kotlinx.rpc.codegen + +import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext +import org.jetbrains.kotlin.backend.common.ir.createExtensionReceiver +import org.jetbrains.kotlin.cli.common.messages.MessageCollector +import org.jetbrains.kotlin.config.CommonConfigurationKeys +import org.jetbrains.kotlin.config.CompilerConfigurationKey +import org.jetbrains.kotlin.descriptors.SourceElement +import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder +import org.jetbrains.kotlin.ir.declarations.* +import org.jetbrains.kotlin.ir.expressions.IrCall +import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin +import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl +import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl +import org.jetbrains.kotlin.ir.symbols.IrClassSymbol +import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol +import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol +import org.jetbrains.kotlin.ir.types.IrType +import org.jetbrains.kotlin.ir.util.copyTo +import org.jetbrains.kotlin.name.CallableId +import org.jetbrains.kotlin.name.ClassId +import org.jetbrains.kotlin.name.FqName +import org.jetbrains.kotlin.name.Name +import org.jetbrains.kotlin.platform.TargetPlatform +import org.jetbrains.kotlin.platform.isJs +import org.jetbrains.kotlin.platform.isWasm + +object VersionSpecificApiImpl : VersionSpecificApi { + override fun isJs(platform: TargetPlatform?): Boolean { + return platform.isJs() + } + + override fun isWasm(platform: TargetPlatform?): Boolean { + return platform.isWasm() + } + + override var IrFieldBuilder.isFinalVS: Boolean + get() = isFinal + set(value) { + isFinal = value + } + + override var IrCall.originVS: IrStatementOrigin? + get() = origin + set(value) { + origin = value + } + + override var IrConstructor.isPrimaryVS: Boolean + get() = isPrimary + set(value) { + isPrimary = value + } + + override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? { + return context.referenceClass( + ClassId( + FqName(packageName), + FqName(name), + false + ) + ) + } + + override fun referenceFunctions( + context: IrPluginContext, + packageName: String, + name: String, + ): Collection { + return context.referenceFunctions( + CallableId( + FqName(packageName), + Name.identifier(name), + ) + ) + } + + override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter { + return copyTo(irFunction, origin) + } + + override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter { + return createExtensionReceiver(type, origin) + } + + override val messageCollectorKey: CompilerConfigurationKey + get() = CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY + + override fun IrCallImplVS( + startOffset: Int, + endOffset: Int, + type: IrType, + symbol: IrSimpleFunctionSymbol, + typeArgumentsCount: Int, + valueArgumentsCount: Int, + origin: IrStatementOrigin?, + superQualifierSymbol: IrClassSymbol?, + ): IrCallImpl { + return IrCallImpl( + startOffset = startOffset, + endOffset = endOffset, + type = type, + symbol = symbol, + typeArgumentsCount = typeArgumentsCount, + origin = origin, + superQualifierSymbol = superQualifierSymbol, + ) + } + + override fun IrConstructorCallImplVS( + startOffset: Int, + endOffset: Int, + type: IrType, + symbol: IrConstructorSymbol, + typeArgumentsCount: Int, + valueArgumentsCount: Int, + constructorTypeArgumentsCount: Int, + origin: IrStatementOrigin?, + source: SourceElement, + ): IrConstructorCallImpl { + return IrConstructorCallImpl( + startOffset = startOffset, + endOffset = endOffset, + type = type, + symbol = symbol, + typeArgumentsCount = typeArgumentsCount, + constructorTypeArgumentsCount = constructorTypeArgumentsCount, + origin = origin, + source = source, + ) + } +} diff --git a/gradle-conventions/common/src/main/kotlin/util/apiValidation.kt b/gradle-conventions/common/src/main/kotlin/util/apiValidation.kt index bf277e849..4edb4b829 100644 --- a/gradle-conventions/common/src/main/kotlin/util/apiValidation.kt +++ b/gradle-conventions/common/src/main/kotlin/util/apiValidation.kt @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ package util @@ -11,13 +11,15 @@ import org.gradle.kotlin.dsl.the fun Project.configureApiValidation() { plugins.apply(libs.plugins.binary.compatibility.validator.get().pluginId) + val kotlinMasterBuild by optionalProperty() + the().apply { ignoredPackages.add("kotlinx.rpc.internal") ignoredPackages.add("kotlinx.rpc.krpc.internal") ignoredProjects.addAll( - listOf( - "compiler-plugin-tests", + listOfNotNull( + if (kotlinMasterBuild) null else "compiler-plugin-tests", "krpc-test", "utils", ) diff --git a/settings.gradle.kts b/settings.gradle.kts index 63f37299e..39f557186 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,5 +1,5 @@ /* - * Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. + * Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. */ rootProject.name = "kotlinx-rpc" @@ -59,6 +59,11 @@ includePublic(":krpc:krpc-ktor:krpc-ktor-server") includePublic(":krpc:krpc-ktor:krpc-ktor-client") include(":tests") -include(":tests:compiler-plugin-tests") + +val kotlinMasterBuild = providers.gradleProperty("kotlinx.rpc.kotlinMasterBuild").orNull == "true" + +if (!kotlinMasterBuild) { + include(":tests:compiler-plugin-tests") +} include(":jpms-check")