Skip to content

Commit

Permalink
Remove configurations and code for Kotlin versions prior to 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr3zee committed Oct 30, 2024
1 parent 6bfe865 commit 7f4289a
Show file tree
Hide file tree
Showing 65 changed files with 79 additions and 1,501 deletions.
7 changes: 2 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,8 @@ Integrations in progress:
- Integration with [gRPC](https://grpc.io/) (in prototype)

## Kotlin compatibility
We support all stable Kotlin versions starting from 1.7.0:
- 1.7.0, 1.7.10, 1.7.20, 1.7.21, 1.7.22
- 1.8.0, 1.8.10, 1.8.20, 1.8.21, 1.8.22
- 1.9.0, 1.9.10, 1.9.20, 1.9.21, 1.9.22, 1.9.23, 1.9.24, 1.9.25
- 2.0.0, 2.0.10
We support all stable Kotlin versions starting from 2.0.0:
- 2.0.0, 2.0.10, 2.0.20, 2.0.21

To simplify project configuration, our Gradle plugin sets a proper library version automatically using BOM,
based on the project's Kotlin version:
Expand Down
7 changes: 1 addition & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,7 @@ plugins {
alias(libs.plugins.conventions.kover)
alias(libs.plugins.conventions.gradle.doctor)
alias(libs.plugins.binary.compatibility.validator)

if (libs.versions.atomicfu.get() >= "0.24.0") {
alias(libs.plugins.atomicfu.new)
} else {
alias(libs.plugins.atomicfu.old)
}
alias(libs.plugins.atomicfu)
}

// useful for dependencies introspection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.ir.declarations.IrProperty
import org.jetbrains.kotlin.ir.declarations.IrSimpleFunction
import org.jetbrains.kotlin.ir.types.classOrNull
import org.jetbrains.kotlin.ir.util.dumpKotlinLike
import org.jetbrains.kotlin.ir.util.packageFqName

/**
* This class scans user declared RPC service
Expand Down Expand Up @@ -73,15 +72,8 @@ internal object RPCDeclarationScanner {
}
}

val packageName = service.packageFqName?.asString()
?: error("Expected package name of the ${service.name.asString()}")

val stubClassNotNull = stubClass
// only for KSP generation
?: ctx.getIrClassSymbol(
packageName = packageName,
name = "${service.name.asString()}${RpcNames.SERVICE_STUB_NAME_KSP.asString()}"
).owner
?: error("Expected generated stub class to be present in ${service.name.asString()}. FIR failed to do so.")

return ServiceDeclaration(
service = service,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ package kotlinx.rpc.codegen.extension
import kotlinx.rpc.codegen.VersionSpecificApi
import kotlinx.rpc.codegen.VersionSpecificApiImpl.copyToVS
import kotlinx.rpc.codegen.common.rpcMethodClassName
import kotlinx.rpc.codegen.common.rpcMethodClassNameKsp
import org.jetbrains.kotlin.backend.common.lower.DeclarationIrBuilder
import org.jetbrains.kotlin.backend.jvm.functionByName
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
Expand Down Expand Up @@ -156,7 +155,7 @@ internal class RPCStubGenerator(
propertyName: String,
propertyType: IrType,
valueParameter: IrValueParameter,
propertyVisibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE
propertyVisibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE,
): IrProperty {
return addConstructorProperty(Name.identifier(propertyName), propertyType, valueParameter, propertyVisibility)
}
Expand All @@ -165,7 +164,7 @@ internal class RPCStubGenerator(
propertyName: Name,
propertyType: IrType,
valueParameter: IrValueParameter,
propertyVisibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE
propertyVisibility: DescriptorVisibility = DescriptorVisibilities.PRIVATE,
): IrProperty {
return addProperty {
name = propertyName
Expand Down Expand Up @@ -537,8 +536,7 @@ internal class RPCStubGenerator(
val isMethodObject = method.arguments.isEmpty()

val methodClassName = method.function.name.rpcMethodClassName
val methodClassNameKsp = method.function.name.rpcMethodClassNameKsp
val methodClass: IrClass = initiateAndGetMethodClass(methodClassName, methodClassNameKsp, method)
val methodClass: IrClass = initiateAndGetMethodClass(methodClassName, method)

addFunction {
name = method.function.name
Expand Down Expand Up @@ -652,17 +650,12 @@ internal class RPCStubGenerator(
* }
* ```
*/
private fun IrClass.initiateAndGetMethodClass(
methodClassName: Name,
methodClassNameKsp: Name,
method: ServiceDeclaration.Method
): IrClass {
val methodClass = findDeclaration<IrClass> {
it.name == methodClassName || it.name == methodClassNameKsp
} ?: error(
"Expected $methodClassName or $methodClassNameKsp class to be present in stub class " +
"${declaration.service.name}${declaration.stubClass.name}"
)
private fun IrClass.initiateAndGetMethodClass(methodClassName: Name, method: ServiceDeclaration.Method): IrClass {
val methodClass = findDeclaration<IrClass> { it.name == methodClassName }
?: error(
"Expected $methodClassName class to be present in stub class " +
"${declaration.service.name}${declaration.stubClass.name}"
)

methodClasses.add(methodClass)

Expand Down Expand Up @@ -764,7 +757,7 @@ internal class RPCStubGenerator(
functionThisReceiver: IrValueParameter,
isMethodObject: Boolean,
methodClass: IrClass,
arguments: List<IrValueParameter>
arguments: List<IrValueParameter>,
): IrCall {
val call = irCall(
callee = ctx.functions.rpcClientCall.symbol,
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 7f4289a

Please sign in to comment.