Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Kotlin 2.0.21 and 2.0.20 #217

Merged
merged 2 commits into from
Oct 30, 2024
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
1 change: 1 addition & 0 deletions compiler-plugin/compiler-plugin-k2/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ kotlin {
}

dependencies {
compileOnly(libs.kotlin.reflect)
compileOnly(libs.kotlin.compiler.embeddable)
project.whenKotlinIsAtLeast(2, 0) {
compileOnly(libs.serialization.plugin)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ import org.jetbrains.kotlin.fir.moduleData
import org.jetbrains.kotlin.fir.plugin.*
import org.jetbrains.kotlin.fir.symbols.SymbolInternals
import org.jetbrains.kotlin.fir.symbols.impl.*
import org.jetbrains.kotlin.fir.types.*
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.classId
import org.jetbrains.kotlin.fir.types.constructClassLikeType
import org.jetbrains.kotlin.name.CallableId
import org.jetbrains.kotlin.name.ClassId
import org.jetbrains.kotlin.name.Name
Expand Down Expand Up @@ -221,9 +224,11 @@ class FirRpcServiceGenerator(
SerialEntityNames.SERIALIZER_FACTORY_INTERFACE_NAME,
)

val ref = serializerFactoryClassId
.constructClassLikeType(emptyArray(), false)
.toFirResolvedTypeRef()
val ref = vsApi {
serializerFactoryClassId
.constructClassLikeType(emptyArray(), false)
.toFirResolvedTypeRefVS()
}

return listOf(ref)
}
Expand Down Expand Up @@ -257,7 +262,7 @@ class FirRpcServiceGenerator(
.map { it.symbol }

return createNestedClass(owner, RpcNames.SERVICE_STUB_NAME, RPCGeneratedStubKey(owner.name, functions)) {
visibility = owner.visibility
visibility = Visibilities.Public
modality = Modality.FINAL
}.symbol
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import org.jetbrains.kotlin.fir.extensions.FirSupertypeGenerationExtension
import org.jetbrains.kotlin.fir.extensions.predicateBasedProvider
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.constructClassLikeType
import org.jetbrains.kotlin.fir.types.toFirResolvedTypeRef

class FirRpcSupertypeGenerator(
session: FirSession,
Expand All @@ -37,9 +36,11 @@ class FirRpcSupertypeGenerator(
}

return listOf(
RpcClassId.remoteServiceInterface
.constructClassLikeType(emptyArray(), isNullable = false)
.toFirResolvedTypeRef()
vsApi {
RpcClassId.remoteServiceInterface
.constructClassLikeType(emptyArray(), isNullable = false)
.toFirResolvedTypeRefVS()
}
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Copyright 2023-2024 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.KtSourceElement
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef

interface FirVersionSpecificApi {
fun ConeKotlinType.toFirResolvedTypeRefVS(
source: KtSourceElement? = null,
delegatedTypeRef: FirTypeRef? = null,
): FirResolvedTypeRef
}

fun <T> vsApi(body: FirVersionSpecificApi.() -> T) : T {
val klass = Class.forName("kotlinx.rpc.codegen.FirVersionSpecificApiImpl")
return (klass.kotlin.objectInstance as FirVersionSpecificApi).body()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2023-2024 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.KtSourceElement
import org.jetbrains.kotlin.fir.toFirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef

@Suppress("unused")
object FirVersionSpecificApiImpl : FirVersionSpecificApi {
override fun ConeKotlinType.toFirResolvedTypeRefVS(
source: KtSourceElement?,
delegatedTypeRef: FirTypeRef?,
): FirResolvedTypeRef {
return toFirResolvedTypeRef(source, delegatedTypeRef)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Copyright 2023-2024 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.KtSourceElement
import org.jetbrains.kotlin.fir.types.ConeKotlinType
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
import org.jetbrains.kotlin.fir.types.FirTypeRef
import org.jetbrains.kotlin.fir.types.toFirResolvedTypeRef

@Suppress("unused")
object FirVersionSpecificApiImpl : FirVersionSpecificApi {
override fun ConeKotlinType.toFirResolvedTypeRefVS(
source: KtSourceElement?,
delegatedTypeRef: FirTypeRef?,
): FirResolvedTypeRef {
return toFirResolvedTypeRef(source, delegatedTypeRef)
}
}
Loading