-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added compiler tests for generic checks
- Loading branch information
Showing
4 changed files
with
181 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
tests/compiler-plugin-tests/src/testData/diagnostics/rpcService.fir.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
FILE: rpcService.kt | ||
@FILE:R|kotlin/OptIn|(markerClass = vararg(<getClass>(Q|kotlinx/rpc/internal/utils/ExperimentalRpcApi|))) | ||
@R|kotlinx/rpc/annotations/Rpc|() public abstract interface MyService : R|kotlin/Any|, R|kotlinx/rpc/RemoteService| { | ||
public abstract fun hello(): R|kotlin/Unit| | ||
|
||
public abstract suspend fun <T> generic(a: R|T|): R|kotlin/Unit| | ||
|
||
public abstract suspend fun <T, T2, T3, T4 : R|kotlin/collections/List<T>|> generic2(a: R|T|, b: R|kotlin/Int|, c: R|T4|, t2: R|T2|): R|T3| | ||
|
||
public abstract suspend fun sameName(): R|kotlin/Unit| | ||
|
||
public abstract suspend fun sameName(a: R|kotlin/Int|): R|kotlin/Unit| | ||
|
||
public abstract suspend fun sameName(a: R|kotlin/Int|, b: R|kotlin/Int|): R|kotlin/Unit| | ||
|
||
public abstract suspend fun sameName(a: R|kotlin/Int|, b: R|kotlin/Int|, c: R|kotlin/Int|): R|kotlin/Unit| | ||
|
||
public abstract suspend fun sameName2(): R|kotlin/Unit| | ||
|
||
public abstract suspend fun sameName2(a: R|kotlin/Int|): R|kotlin/Unit| | ||
|
||
public final class $rpcServiceStub : R|kotlin/Any| { | ||
@R|kotlinx/serialization/Serializable|() public final object hello$rpcMethod : R|kotlin/Any| { | ||
public final fun serializer(): R|kotlinx/serialization/KSerializer<MyService.$rpcServiceStub.hello$rpcMethod>| | ||
|
||
private constructor(): R|MyService.$rpcServiceStub.hello$rpcMethod| { | ||
super<R|kotlin/Any|>() | ||
} | ||
|
||
} | ||
|
||
@R|kotlinx/serialization/Serializable|() public final class generic$rpcMethod : R|kotlin/Any| { | ||
public final val a: R|T| | ||
public get(): R|T| | ||
|
||
public constructor(a: R|T|): R|MyService.$rpcServiceStub.generic$rpcMethod| | ||
|
||
public final companion object Companion : R|kotlin/Any| { | ||
public final fun serializer(): R|kotlinx/serialization/KSerializer<MyService.$rpcServiceStub.generic$rpcMethod>| | ||
|
||
private constructor(): R|MyService.$rpcServiceStub.generic$rpcMethod.Companion| { | ||
super<R|kotlin/Any|>() | ||
} | ||
|
||
} | ||
|
||
@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final object $serializer : R|kotlinx/serialization/internal/GeneratedSerializer<MyService.$rpcServiceStub.generic$rpcMethod>| { | ||
public final override fun serialize(encoder: R|kotlinx/serialization/encoding/Encoder|, value: R|MyService.$rpcServiceStub.generic$rpcMethod|): R|kotlin/Unit| | ||
|
||
public final override fun deserialize(decoder: R|kotlinx/serialization/encoding/Decoder|): R|MyService.$rpcServiceStub.generic$rpcMethod| | ||
|
||
public final val descriptor: R|kotlinx/serialization/descriptors/SerialDescriptor| | ||
public get(): R|kotlinx/serialization/descriptors/SerialDescriptor| | ||
|
||
public final override fun childSerializers(): R|kotlin/Array<kotlinx/serialization/KSerializer<*>>| | ||
|
||
private constructor(): R|MyService.$rpcServiceStub.generic$rpcMethod.$serializer| { | ||
super<R|kotlin/Any|>() | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
@R|kotlinx/serialization/Serializable|() public final class generic2$rpcMethod : R|kotlin/Any| { | ||
public final val a: R|T| | ||
public get(): R|T| | ||
|
||
public final val b: R|kotlin/Int| | ||
public get(): R|kotlin/Int| | ||
|
||
public final val c: R|T4| | ||
public get(): R|T4| | ||
|
||
public final val t2: R|T2| | ||
public get(): R|T2| | ||
|
||
public constructor(a: R|T|, b: R|kotlin/Int|, c: R|T4|, t2: R|T2|): R|MyService.$rpcServiceStub.generic2$rpcMethod| | ||
|
||
public final companion object Companion : R|kotlin/Any| { | ||
public final fun serializer(): R|kotlinx/serialization/KSerializer<MyService.$rpcServiceStub.generic2$rpcMethod>| | ||
|
||
private constructor(): R|MyService.$rpcServiceStub.generic2$rpcMethod.Companion| { | ||
super<R|kotlin/Any|>() | ||
} | ||
|
||
} | ||
|
||
@R|kotlin/Deprecated|(message = String(This synthesized declaration should not be used directly), level = Q|kotlin/DeprecationLevel|.R|kotlin/DeprecationLevel.HIDDEN|) public final object $serializer : R|kotlinx/serialization/internal/GeneratedSerializer<MyService.$rpcServiceStub.generic2$rpcMethod>| { | ||
public final override fun serialize(encoder: R|kotlinx/serialization/encoding/Encoder|, value: R|MyService.$rpcServiceStub.generic2$rpcMethod|): R|kotlin/Unit| | ||
|
||
public final override fun deserialize(decoder: R|kotlinx/serialization/encoding/Decoder|): R|MyService.$rpcServiceStub.generic2$rpcMethod| | ||
|
||
public final val descriptor: R|kotlinx/serialization/descriptors/SerialDescriptor| | ||
public get(): R|kotlinx/serialization/descriptors/SerialDescriptor| | ||
|
||
public final override fun childSerializers(): R|kotlin/Array<kotlinx/serialization/KSerializer<*>>| | ||
|
||
private constructor(): R|MyService.$rpcServiceStub.generic2$rpcMethod.$serializer| { | ||
super<R|kotlin/Any|>() | ||
} | ||
|
||
} | ||
|
||
} | ||
|
||
public final companion object Companion : R|kotlin/Any| { | ||
} | ||
|
||
} | ||
|
||
} | ||
@R|kotlinx/rpc/annotations/Rpc|() public abstract interface MyServiceT<T> : R|kotlin/Any|, R|kotlinx/rpc/RemoteService| { | ||
public final class $rpcServiceStub : R|kotlin/Any| { | ||
public final companion object Companion : R|kotlin/Any| { | ||
} | ||
|
||
} | ||
|
||
} | ||
@R|kotlinx/rpc/annotations/Rpc|() public abstract interface MyServiceT2<T, R, A, B> : R|kotlin/Any|, R|kotlinx/rpc/RemoteService| { | ||
public final class $rpcServiceStub : R|kotlin/Any| { | ||
public final companion object Companion : R|kotlin/Any| { | ||
} | ||
|
||
} | ||
|
||
} |
44 changes: 44 additions & 0 deletions
44
tests/compiler-plugin-tests/src/testData/diagnostics/rpcService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* Copyright 2023-2024 JetBrains s.r.o and contributors. Use of this source code is governed by the Apache 2.0 license. | ||
*/ | ||
|
||
@file:OptIn(ExperimentalRpcApi::class) | ||
|
||
import kotlin.coroutines.* | ||
import kotlinx.coroutines.* | ||
import kotlinx.coroutines.flow.* | ||
import kotlinx.serialization.Serializable | ||
import kotlinx.serialization.Contextual | ||
import kotlinx.rpc.annotations.Rpc | ||
import kotlinx.rpc.krpc.streamScoped | ||
import kotlinx.rpc.krpc.withStreamScope | ||
import kotlinx.rpc.krpc.StreamScope | ||
import kotlinx.rpc.krpc.invokeOnStreamScopeCompletion | ||
import kotlinx.rpc.internal.utils.ExperimentalRpcApi | ||
|
||
@Rpc | ||
interface MyService { | ||
<!NON_SUSPENDING_REQUEST_WITHOUT_STREAMING_RETURN_TYPE!>fun hello()<!> | ||
|
||
suspend fun <!TYPE_PARAMETERS_IN_RPC_FUNCTION!><T><!> generic(a: T) | ||
|
||
suspend fun <!TYPE_PARAMETERS_IN_RPC_FUNCTION!><T, T2, T3, T4 : List<T>><!> generic2(a: T, b: Int, c: T4, t2: T2): T3 | ||
|
||
<!AD_HOC_POLYMORPHISM_IN_RPC_SERVICE!>suspend fun sameName()<!> | ||
|
||
<!AD_HOC_POLYMORPHISM_IN_RPC_SERVICE!>suspend fun sameName(a: Int)<!> | ||
|
||
<!AD_HOC_POLYMORPHISM_IN_RPC_SERVICE!>suspend fun sameName(a: Int, b: Int)<!> | ||
|
||
<!AD_HOC_POLYMORPHISM_IN_RPC_SERVICE!>suspend fun sameName(a: Int, b: Int, c: Int)<!> | ||
|
||
<!AD_HOC_POLYMORPHISM_IN_RPC_SERVICE!>suspend fun sameName2()<!> | ||
|
||
<!AD_HOC_POLYMORPHISM_IN_RPC_SERVICE!>suspend fun sameName2(a: Int)<!> | ||
} | ||
|
||
@Rpc | ||
interface MyServiceT<!TYPE_PARAMETERS_IN_RPC_INTERFACE!><T><!> | ||
|
||
@Rpc | ||
interface MyServiceT2<!TYPE_PARAMETERS_IN_RPC_INTERFACE!><T, R, A, B><!> |