Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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<IrSimpleFunctionSymbol> {
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<MessageCollector>
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,
)
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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<ApiValidationExtension>().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",
)
Expand Down
9 changes: 7 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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")