Skip to content

Commit 13e4780

Browse files
authored
Fix kotlin master (#274)
1 parent 203e966 commit 13e4780

File tree

3 files changed

+148
-5
lines changed

3 files changed

+148
-5
lines changed
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/*
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
3+
*/
4+
5+
package kotlinx.rpc.codegen
6+
7+
import org.jetbrains.kotlin.backend.common.extensions.IrPluginContext
8+
import org.jetbrains.kotlin.backend.common.ir.createExtensionReceiver
9+
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
10+
import org.jetbrains.kotlin.config.CommonConfigurationKeys
11+
import org.jetbrains.kotlin.config.CompilerConfigurationKey
12+
import org.jetbrains.kotlin.descriptors.SourceElement
13+
import org.jetbrains.kotlin.ir.builders.declarations.IrFieldBuilder
14+
import org.jetbrains.kotlin.ir.declarations.*
15+
import org.jetbrains.kotlin.ir.expressions.IrCall
16+
import org.jetbrains.kotlin.ir.expressions.IrStatementOrigin
17+
import org.jetbrains.kotlin.ir.expressions.impl.IrCallImpl
18+
import org.jetbrains.kotlin.ir.expressions.impl.IrConstructorCallImpl
19+
import org.jetbrains.kotlin.ir.symbols.IrClassSymbol
20+
import org.jetbrains.kotlin.ir.symbols.IrConstructorSymbol
21+
import org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
22+
import org.jetbrains.kotlin.ir.types.IrType
23+
import org.jetbrains.kotlin.ir.util.copyTo
24+
import org.jetbrains.kotlin.name.CallableId
25+
import org.jetbrains.kotlin.name.ClassId
26+
import org.jetbrains.kotlin.name.FqName
27+
import org.jetbrains.kotlin.name.Name
28+
import org.jetbrains.kotlin.platform.TargetPlatform
29+
import org.jetbrains.kotlin.platform.isJs
30+
import org.jetbrains.kotlin.platform.isWasm
31+
32+
object VersionSpecificApiImpl : VersionSpecificApi {
33+
override fun isJs(platform: TargetPlatform?): Boolean {
34+
return platform.isJs()
35+
}
36+
37+
override fun isWasm(platform: TargetPlatform?): Boolean {
38+
return platform.isWasm()
39+
}
40+
41+
override var IrFieldBuilder.isFinalVS: Boolean
42+
get() = isFinal
43+
set(value) {
44+
isFinal = value
45+
}
46+
47+
override var IrCall.originVS: IrStatementOrigin?
48+
get() = origin
49+
set(value) {
50+
origin = value
51+
}
52+
53+
override var IrConstructor.isPrimaryVS: Boolean
54+
get() = isPrimary
55+
set(value) {
56+
isPrimary = value
57+
}
58+
59+
override fun referenceClass(context: IrPluginContext, packageName: String, name: String): IrClassSymbol? {
60+
return context.referenceClass(
61+
ClassId(
62+
FqName(packageName),
63+
FqName(name),
64+
false
65+
)
66+
)
67+
}
68+
69+
override fun referenceFunctions(
70+
context: IrPluginContext,
71+
packageName: String,
72+
name: String,
73+
): Collection<IrSimpleFunctionSymbol> {
74+
return context.referenceFunctions(
75+
CallableId(
76+
FqName(packageName),
77+
Name.identifier(name),
78+
)
79+
)
80+
}
81+
82+
override fun IrValueParameter.copyToVS(irFunction: IrFunction, origin: IrDeclarationOrigin): IrValueParameter {
83+
return copyTo(irFunction, origin)
84+
}
85+
86+
override fun IrSimpleFunction.addExtensionReceiverVS(type: IrType, origin: IrDeclarationOrigin): IrValueParameter {
87+
return createExtensionReceiver(type, origin)
88+
}
89+
90+
override val messageCollectorKey: CompilerConfigurationKey<MessageCollector>
91+
get() = CommonConfigurationKeys.MESSAGE_COLLECTOR_KEY
92+
93+
override fun IrCallImplVS(
94+
startOffset: Int,
95+
endOffset: Int,
96+
type: IrType,
97+
symbol: IrSimpleFunctionSymbol,
98+
typeArgumentsCount: Int,
99+
valueArgumentsCount: Int,
100+
origin: IrStatementOrigin?,
101+
superQualifierSymbol: IrClassSymbol?,
102+
): IrCallImpl {
103+
return IrCallImpl(
104+
startOffset = startOffset,
105+
endOffset = endOffset,
106+
type = type,
107+
symbol = symbol,
108+
typeArgumentsCount = typeArgumentsCount,
109+
origin = origin,
110+
superQualifierSymbol = superQualifierSymbol,
111+
)
112+
}
113+
114+
override fun IrConstructorCallImplVS(
115+
startOffset: Int,
116+
endOffset: Int,
117+
type: IrType,
118+
symbol: IrConstructorSymbol,
119+
typeArgumentsCount: Int,
120+
valueArgumentsCount: Int,
121+
constructorTypeArgumentsCount: Int,
122+
origin: IrStatementOrigin?,
123+
source: SourceElement,
124+
): IrConstructorCallImpl {
125+
return IrConstructorCallImpl(
126+
startOffset = startOffset,
127+
endOffset = endOffset,
128+
type = type,
129+
symbol = symbol,
130+
typeArgumentsCount = typeArgumentsCount,
131+
constructorTypeArgumentsCount = constructorTypeArgumentsCount,
132+
origin = origin,
133+
source = source,
134+
)
135+
}
136+
}

gradle-conventions/common/src/main/kotlin/util/apiValidation.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
package util
@@ -11,13 +11,15 @@ import org.gradle.kotlin.dsl.the
1111
fun Project.configureApiValidation() {
1212
plugins.apply(libs.plugins.binary.compatibility.validator.get().pluginId)
1313

14+
val kotlinMasterBuild by optionalProperty()
15+
1416
the<ApiValidationExtension>().apply {
1517
ignoredPackages.add("kotlinx.rpc.internal")
1618
ignoredPackages.add("kotlinx.rpc.krpc.internal")
1719

1820
ignoredProjects.addAll(
19-
listOf(
20-
"compiler-plugin-tests",
21+
listOfNotNull(
22+
if (kotlinMasterBuild) null else "compiler-plugin-tests",
2123
"krpc-test",
2224
"utils",
2325
)

settings.gradle.kts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
2+
* Copyright 2023-2025 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license.
33
*/
44

55
rootProject.name = "kotlinx-rpc"
@@ -59,6 +59,11 @@ includePublic(":krpc:krpc-ktor:krpc-ktor-server")
5959
includePublic(":krpc:krpc-ktor:krpc-ktor-client")
6060

6161
include(":tests")
62-
include(":tests:compiler-plugin-tests")
62+
63+
val kotlinMasterBuild = providers.gradleProperty("kotlinx.rpc.kotlinMasterBuild").orNull == "true"
64+
65+
if (!kotlinMasterBuild) {
66+
include(":tests:compiler-plugin-tests")
67+
}
6368

6469
include(":jpms-check")

0 commit comments

Comments
 (0)